mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
remove panicking and added usage (#6208)
This commit is contained in:
committed by
Brian Kassouf
parent
b888adec50
commit
75266af3d3
@@ -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
43
command/print.go
Normal 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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user