From f463ab9d9b19177e5c8e9bc4df32d0b68d1fbdab Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Mon, 6 Mar 2017 16:37:41 -0600 Subject: [PATCH] make inspect behave like pilosactl version --- cmd/inspect.go | 19 +++++++++---------- cmd/sort.go | 1 - 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cmd/inspect.go b/cmd/inspect.go index 48bbf8308..56ded3bb7 100644 --- a/cmd/inspect.go +++ b/cmd/inspect.go @@ -3,11 +3,9 @@ package cmd import ( "context" "fmt" - "log" "os" "github.com/spf13/cobra" - "github.com/spf13/viper" "github.com/pilosa/pilosa/ctl" ) @@ -16,11 +14,19 @@ var inspecter = ctl.NewInspectCommand(os.Stdin, os.Stdout, os.Stderr) var inspectCmd = &cobra.Command{ Use: "inspect", - Short: "inspect - inspect a pilosa data file", + Short: "get stats on pilosa data file", Long: ` Inspects a data file and provides stats. `, Run: func(cmd *cobra.Command, args []string) { + if len(args) == 0 { + fmt.Println("path required") + return + } else if len(args) > 1 { + fmt.Println("only one path allowed") + return + } + inspecter.Path = args[0] if err := inspecter.Run(context.Background()); err != nil { fmt.Println(err) } @@ -28,12 +34,5 @@ Inspects a data file and provides stats. } func init() { - inspectCmd.Flags().StringVarP(&inspecter.Path, "file", "i", "", "File to inspect") - - err := viper.BindPFlags(inspectCmd.Flags()) - if err != nil { - log.Fatalf("Error binding inspect flags: %v", err) - } - RootCmd.AddCommand(inspectCmd) } diff --git a/cmd/sort.go b/cmd/sort.go index 813624ddc..4df585629 100644 --- a/cmd/sort.go +++ b/cmd/sort.go @@ -25,7 +25,6 @@ The format of the CSV file is: The file should contain no headers. `, Run: func(cmd *cobra.Command, args []string) { - fmt.Println(cmd.Flags()) if len(args) == 0 { fmt.Println("path required") return