remove panicking and added usage (#6208)

This commit is contained in:
Giacomo Tirabassi
2019-02-11 20:19:08 +01:00
committed by Brian Kassouf
parent b888adec50
commit 75266af3d3
3 changed files with 50 additions and 7 deletions

View File

@@ -425,6 +425,11 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
BaseCommand: getBaseCommand(),
}, nil
},
"print": func() (cli.Command, error) {
return &PrintCommand{
BaseCommand: getBaseCommand(),
}, nil
},
"print token": func() (cli.Command, error) {
return &PrintTokenCommand{
BaseCommand: getBaseCommand(),

43
command/print.go Normal file
View File

@@ -0,0 +1,43 @@
package command
import (
"strings"
"github.com/mitchellh/cli"
"github.com/posener/complete"
)
var _ cli.Command = (*PrintCommand)(nil)
var _ cli.CommandAutocomplete = (*PrintCommand)(nil)
type PrintCommand struct {
*BaseCommand
}
func (c *PrintCommand) Synopsis() string {
return "Prints runtime configurations"
}
func (c *PrintCommand) Help() string {
helpText := `
Usage: vault print <subcommand>
This command groups subcommands for interacting with Vault's runtime values.
Subcommands:
token Token currently in use
`
return strings.TrimSpace(helpText)
}
func (c *PrintCommand) AutocompleteArgs() complete.Predictor {
return nil
}
func (c *PrintCommand) AutocompleteFlags() complete.Flags {
return nil
}
func (c *PrintCommand) Run(args []string) int {
return cli.RunResultHelp
}

View File

@@ -15,7 +15,7 @@ type PrintTokenCommand struct {
}
func (c *PrintTokenCommand) Synopsis() string {
return "Prints the contents of a policy"
return "Prints the vault token currenty in use"
}
func (c *PrintTokenCommand) Help() string {
@@ -27,15 +27,10 @@ Usage: vault print token
$ vault print token
` + c.Flags().Help()
`
return strings.TrimSpace(helpText)
}
func (c *PrintTokenCommand) Flags() *FlagSets {
return nil
}
func (c *PrintTokenCommand) AutocompleteArgs() complete.Predictor {
return nil
}