tweak comments and remove dead code

This commit is contained in:
Matt Jaffee 2017-03-07 11:35:58 -06:00
parent 555a514e37
commit 320110f011
5 changed files with 5 additions and 120 deletions

View file

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

View file

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

View file

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

View file

@ -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 == "" {

View file

@ -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 != "" {