make inspect behave like pilosactl version

This commit is contained in:
Matt Jaffee 2017-03-06 16:37:41 -06:00
parent c419c082da
commit f463ab9d9b
2 changed files with 9 additions and 11 deletions

View file

@ -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)
}

View file

@ -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