Skip to content

Commit

Permalink
Client (#288)
Browse files Browse the repository at this point in the history
* better endpoint collection interface

* prepared client and annactl separation

* updated glide files

* added separate client package to vendor deps

* updated vendor deps
  • Loading branch information
xh3b4sd authored Nov 21, 2016
1 parent 722d4db commit 91f63c5
Show file tree
Hide file tree
Showing 40 changed files with 1,103 additions and 668 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ gofmt:

gogenerate:
@go generate ./service/clg
@protoc --proto_path=vendor/github.com/the-anna-project/spec/api --go_out=plugins=grpc,import_path=text:client/interface/text/ vendor/github.com/the-anna-project/spec/api/text_endpoint.proto
@protoc --proto_path=vendor/github.com/the-anna-project/spec/api --go_out=plugins=grpc,import_path=text:service/endpoint/text/ vendor/github.com/the-anna-project/spec/api/text_endpoint.proto

gotest: gogenerate
Expand Down
26 changes: 0 additions & 26 deletions annactl/annactl_interface.go

This file was deleted.

26 changes: 0 additions & 26 deletions annactl/annactl_interface_text.go

This file was deleted.

26 changes: 0 additions & 26 deletions annactl/annactl_interface_text_read.go

This file was deleted.

69 changes: 0 additions & 69 deletions annactl/annactl_interface_text_read_file.go

This file was deleted.

74 changes: 0 additions & 74 deletions annactl/annactl_interface_text_read_plain.go

This file was deleted.

27 changes: 0 additions & 27 deletions annactl/annactl_version.go

This file was deleted.

66 changes: 66 additions & 0 deletions annactl/command/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package command

import (
"github.com/spf13/cobra"

"github.com/xh3b4sd/anna/annactl/command/endpoint"
"github.com/xh3b4sd/anna/annactl/command/version"
)

// New creates a new annactl command.
func New() *Command {
command := &Command{}

command.SetEndpointCommand(endpoint.New())
command.SetVersionCommand(version.New())

return command
}

// Command represents the annactl command.
type Command struct {
// Dependencies.

endpointCommand *endpoint.Command
versionCommand *version.Command
}

// Execute represents the cobra run method.
func (c *Command) Execute(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, nil)
}

// New creates a new cobra command for the annactl command.
func (c *Command) New() *cobra.Command {
newCommand := &cobra.Command{
Use: "annactl",
Short: "Manage the API of the anna project. For more information see https://github.com/the-anna-project/annactl.",
Long: "Manage the API of the anna project. For more information see https://github.com/the-anna-project/annactl.",
Run: c.Execute,
}

newCommand.AddCommand(c.endpointCommand.New())
newCommand.AddCommand(c.versionCommand.New())

return newCommand
}

// EndpointCommand returns the endpoint subcommand of the annactl command.
func (c *Command) EndpointCommand() *endpoint.Command {
return c.endpointCommand
}

// SetEndpointCommand sets the endpoint subcommand for the annactl command.
func (c *Command) SetEndpointCommand(endpointCommand *endpoint.Command) {
c.endpointCommand = endpointCommand
}

// SetVersionCommand sets the version subcommand for the annactl command.
func (c *Command) SetVersionCommand(versionCommand *version.Command) {
c.versionCommand = versionCommand
}

// VersionCommand returns the version subcommand of the annactl command.
func (c *Command) VersionCommand() *version.Command {
return c.versionCommand
}
52 changes: 52 additions & 0 deletions annactl/command/endpoint/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package endpoint

import (
"github.com/spf13/cobra"

"github.com/xh3b4sd/anna/annactl/command/endpoint/text"
)

// New creates a new endpoint command.
func New() *Command {
command := &Command{}

command.SetTextCommand(text.New())

return command
}

// Command represents the endpoint command.
type Command struct {
// Settings.

textCommand *text.Command
}

// Execute represents the cobra run method.
func (c *Command) Execute(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, nil)
}

// New creates a new cobra command for the endpoint command.
func (c *Command) New() *cobra.Command {
newCommand := &cobra.Command{
Use: "endpoint",
Short: "Manage the network endpoints of the API of the anna project.",
Long: "Manage the network endpoints of the API of the anna project.",
Run: c.Execute,
}

newCommand.AddCommand(c.textCommand.New())

return newCommand
}

// TextCommand returns the text subcommand of the endpoint command.
func (c *Command) TextCommand() *text.Command {
return c.textCommand
}

// SetTextCommand sets the text subcommand for the endpoint command.
func (c *Command) SetTextCommand(textCommand *text.Command) {
c.textCommand = textCommand
}
Loading

0 comments on commit 91f63c5

Please sign in to comment.