From 79d7944728a100fb8f2c8b9cf2a66458357e676f Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Wed, 21 Nov 2018 15:53:19 -0800 Subject: [PATCH] Move --steppath flag to the command `step path` Fixes smallstep/step#133 --- cmd/step/main.go | 20 ++------------------ command/path/path.go | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 command/path/path.go diff --git a/cmd/step/main.go b/cmd/step/main.go index 5b689ceb..0183b12e 100644 --- a/cmd/step/main.go +++ b/cmd/step/main.go @@ -16,12 +16,11 @@ import ( "github.com/smallstep/cli/usage" // Enabled commands + _ "github.com/smallstep/cli/command/ca" _ "github.com/smallstep/cli/command/certificate" _ "github.com/smallstep/cli/command/crypto" _ "github.com/smallstep/cli/command/oauth" - - // Work in progress ... - _ "github.com/smallstep/cli/command/ca" + _ "github.com/smallstep/cli/command/path" // Profiling and debugging _ "net/http/pprof" @@ -68,25 +67,10 @@ func main() { Usage: "path to the config file to use for CLI flags", }) - // Flag for printing the step path - app.Flags = append(app.Flags, cli.BoolFlag{ - Name: "steppath", - Usage: "print the configured step path and exit", - }) - // All non-successful output should be written to stderr app.Writer = os.Stdout app.ErrWriter = os.Stderr - // Default action will print the steppath or help - app.Action = cli.ActionFunc(func(ctx *cli.Context) error { - if ctx.Bool("steppath") { - fmt.Println(config.StepPath()) - return nil - } - return cli.HandleAction(usage.HelpCommandAction, ctx) - }) - // Start the golang debug logger if environment variable is set. // See https://golang.org/pkg/net/http/pprof/ debugProfAddr := os.Getenv("STEP_PROF_ADDR") diff --git a/command/path/path.go b/command/path/path.go new file mode 100644 index 00000000..9ba9e373 --- /dev/null +++ b/command/path/path.go @@ -0,0 +1,24 @@ +package path + +import ( + "fmt" + + "github.com/smallstep/cli/command" + "github.com/smallstep/cli/config" + "github.com/urfave/cli" +) + +func init() { + cmd := cli.Command{ + Name: "path", + Usage: "print the configured step path and exit", + UsageText: "step path", + Description: "**step ca** command prints the configured step path and exit", + Action: cli.ActionFunc(func(ctx *cli.Context) error { + fmt.Println(config.StepPath()) + return nil + }), + } + + command.Register(cmd) +}