Skip to content

Commit

Permalink
Move available connectors listing to `facette' cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
falzm committed Jul 29, 2014
1 parent 428c786 commit bd64385
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
15 changes: 15 additions & 0 deletions cmd/facette/facette.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"fmt"
"os"
"os/signal"
"sort"
"syscall"

"github.com/facette/facette/pkg/connector"
"github.com/facette/facette/pkg/logger"
"github.com/facette/facette/pkg/server"
"github.com/facette/facette/pkg/utils"
Expand Down Expand Up @@ -44,6 +46,19 @@ func init() {
utils.PrintUsage(os.Stdout, cmdUsage)
} else if flagVersion {
utils.PrintVersion(version)

connectors := []string{}
for connector := range connector.Connectors {
connectors = append(connectors, connector)
}

sort.Strings(connectors)

fmt.Printf("\nAvailable connectors:\n")
for _, connector := range connectors {
fmt.Printf(" %s\n", connector)
}

os.Exit(0)
} else if flagConfig == "" {
fmt.Fprintf(os.Stderr, "Error: configuration file path is mandatory\n")
Expand Down
2 changes: 1 addition & 1 deletion cmd/facettectl/facettectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func main() {
}

switch flag.Args()[0] {
case "reload", "support":
case "reload":
handler = handleService
default:
utils.PrintUsage(os.Stderr, cmdUsage)
Expand Down
22 changes: 0 additions & 22 deletions cmd/facettectl/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import (
"fmt"
"io/ioutil"
"os"
"sort"
"strconv"
"strings"
"syscall"

"github.com/facette/facette/pkg/config"
"github.com/facette/facette/pkg/connector"
)

func handleService(config *config.Config, args []string) error {
Expand All @@ -19,8 +17,6 @@ func handleService(config *config.Config, args []string) error {
switch args[0] {
case "reload":
return cmd.reload(args[1:])
case "support":
return cmd.support(args[1:])
}

return nil
Expand Down Expand Up @@ -53,21 +49,3 @@ func (cmd *cmdServer) reload(args []string) error {

return syscall.Kill(pid, syscall.SIGHUP)
}

func (cmd *cmdServer) support(args []string) error {
fmt.Println("Provider connectors:")

keys := []string{}

for key := range connector.Connectors {
keys = append(keys, key)
}

sort.Strings(keys)

for key := range connector.Connectors {
fmt.Printf(" %s\n", key)
}

return nil
}

0 comments on commit bd64385

Please sign in to comment.