From 320110f0116c94a6194cb8a8fa276fbfde6afe9e Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Tue, 7 Mar 2017 11:35:58 -0600 Subject: [PATCH] tweak comments and remove dead code --- ctl/bench.go | 53 +----------------------------------------------- ctl/check.go | 33 +----------------------------- ctl/inspect.go | 35 +------------------------------- ctl/restore.go | 2 +- server/server.go | 2 +- 5 files changed, 5 insertions(+), 120 deletions(-) diff --git a/ctl/bench.go b/ctl/bench.go index 7e789b5cd..2afe7bb27 100644 --- a/ctl/bench.go +++ b/ctl/bench.go @@ -3,12 +3,9 @@ package ctl import ( "context" "errors" - "flag" "fmt" "io" - "io/ioutil" "math/rand" - "strings" "time" "github.com/pilosa/pilosa" @@ -42,55 +39,7 @@ func NewBenchCommand(stdin io.Reader, stdout, stderr io.Writer) *BenchCommand { } } -// ParseFlags parses command line flags from args. -func (cmd *BenchCommand) ParseFlags(args []string) error { - fs := flag.NewFlagSet("pilosactl", flag.ContinueOnError) - fs.SetOutput(ioutil.Discard) - fs.StringVar(&cmd.Host, "host", "localhost:15000", "host:port") - fs.StringVar(&cmd.Database, "d", "", "database") - fs.StringVar(&cmd.Frame, "f", "", "frame") - fs.StringVar(&cmd.Op, "op", "", "operation") - fs.IntVar(&cmd.N, "n", 0, "op count") - - if err := fs.Parse(args); err != nil { - return err - } - return nil -} - -// Usage returns the usage message to be printed. -func (cmd *BenchCommand) Usage() string { - return strings.TrimSpace(` -usage: pilosactl bench [args] - -Executes a benchmark for a given operation against the database. - -The following flags are allowed: - - -host HOSTPORT - hostname and port of running pilosa server - - -d DATABASE - database to execute operation against - - -f FRAME - frame to execute operation against - - -op OP - name of operation to execute - - -n COUNT - number of iterations to execute - -The following operations are available: - - set-bit - Sets a single random bit on the frame - -`) -} - -// Run executes the main program execution. +// Run executes the bench command. func (cmd *BenchCommand) Run(ctx context.Context) error { // Create a client to the server. client, err := pilosa.NewClient(cmd.Host) diff --git a/ctl/check.go b/ctl/check.go index 616e189bf..0893790f2 100644 --- a/ctl/check.go +++ b/ctl/check.go @@ -2,14 +2,10 @@ package ctl import ( "context" - "errors" - "flag" "fmt" "io" - "io/ioutil" "os" "path/filepath" - "strings" "syscall" "github.com/pilosa/pilosa/roaring" @@ -35,34 +31,7 @@ func NewCheckCommand(stdin io.Reader, stdout, stderr io.Writer) *CheckCommand { } } -// ParseFlags parses command line flags from args. -func (cmd *CheckCommand) ParseFlags(args []string) error { - fs := flag.NewFlagSet("pilosactl", flag.ContinueOnError) - fs.SetOutput(ioutil.Discard) - if err := fs.Parse(args); err != nil { - return err - } - - // Parse path. - if fs.NArg() == 0 { - return errors.New("path required") - } - cmd.Paths = fs.Args() - - return nil -} - -// Usage returns the usage message to be printed. -func (cmd *CheckCommand) Usage() string { - return strings.TrimSpace(` -usage: pilosactl check PATHS... - -Performs a consistency check on data files. - -`) -} - -// Run executes the main program execution. +// Run executes the check command. func (cmd *CheckCommand) Run(ctx context.Context) error { for _, path := range cmd.Paths { switch filepath.Ext(path) { diff --git a/ctl/inspect.go b/ctl/inspect.go index 1b00dbcee..86434b131 100644 --- a/ctl/inspect.go +++ b/ctl/inspect.go @@ -2,13 +2,9 @@ package ctl import ( "context" - "errors" - "flag" "fmt" "io" - "io/ioutil" "os" - "strings" "syscall" "text/tabwriter" "time" @@ -37,36 +33,7 @@ func NewInspectCommand(stdin io.Reader, stdout, stderr io.Writer) *InspectComman } } -// ParseFlags parses command line flags from args. -func (cmd *InspectCommand) ParseFlags(args []string) error { - fs := flag.NewFlagSet("pilosactl", flag.ContinueOnError) - fs.SetOutput(ioutil.Discard) - if err := fs.Parse(args); err != nil { - return err - } - - // Parse path. - if fs.NArg() == 0 { - return errors.New("path required") - } else if fs.NArg() > 1 { - return errors.New("only one path allowed") - } - cmd.Path = fs.Arg(0) - - return nil -} - -// Usage returns the usage message to be printed. -func (cmd *InspectCommand) Usage() string { - return strings.TrimSpace(` -usage: pilosactl inspect PATH - -Inspects a data file and provides stats. - -`) -} - -// Run executes the main program execution. +// Run executes the inspect command. func (cmd *InspectCommand) Run(ctx context.Context) error { // Open file handle. f, err := os.Open(cmd.Path) diff --git a/ctl/restore.go b/ctl/restore.go index b9a573704..a650df495 100644 --- a/ctl/restore.go +++ b/ctl/restore.go @@ -36,7 +36,7 @@ func NewRestoreCommand(stdin io.Reader, stdout, stderr io.Writer) *RestoreComman } } -// Run executes the main program execution. +// Run executes the restore command. func (cmd *RestoreCommand) Run(ctx context.Context) error { // Validate arguments. if cmd.Path == "" { diff --git a/server/server.go b/server/server.go index b7b8ca2f9..845340485 100644 --- a/server/server.go +++ b/server/server.go @@ -103,7 +103,7 @@ func (m *Command) Close() error { return m.Server.Close() } -// ParseFlags parses command line flags from args. +// SetupConfig loads the config file if specified and sets state on the Command. func (m *Command) SetupConfig(args []string) error { // Load config, if specified. if m.ConfigPath != "" {