Fix airshipctl config get-context maximum args
Limit the number of arguments that can be passed to get-context command to 1 for now Closes: #526 Change-Id: Ib140fc836e01c284c05719dfb7e3f29d0b191538
This commit is contained in:
parent
a0cfddab1b
commit
f70e93762f
@ -44,10 +44,12 @@ airshipctl config get-context exampleContext
|
||||
func NewGetContextCommand(cfgFactory config.Factory) *cobra.Command {
|
||||
o := &config.ContextOptions{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "get-context [NAME]",
|
||||
Use: "get-context CONTEXT_NAME",
|
||||
Short: "Get context information from the airshipctl config",
|
||||
Long: getContextLong[1:],
|
||||
Example: getContextExample,
|
||||
// Adding a maximum args cap for documentation purpose
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
Aliases: []string{"get-contexts"},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
airconfig, err := cfgFactory()
|
||||
|
@ -50,7 +50,7 @@ func TestGetContextCmd(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Name: "get-all-contexts",
|
||||
CmdLine: fmt.Sprintf("%s %s", fooContext, barContext),
|
||||
CmdLine: fmt.Sprintf("%s", barContext),
|
||||
Cmd: cmd.NewGetContextCommand(settings),
|
||||
},
|
||||
// This is not implemented yet
|
||||
@ -58,6 +58,7 @@ func TestGetContextCmd(t *testing.T) {
|
||||
Name: "get-multiple-contexts",
|
||||
CmdLine: fmt.Sprintf("%s %s", fooContext, barContext),
|
||||
Cmd: cmd.NewGetContextCommand(settings),
|
||||
Error: fmt.Errorf("accepts at most 1 arg(s), received 2"),
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -1,9 +1,3 @@
|
||||
managementConfiguration: ""
|
||||
manifest: Manifest_ContextBar
|
||||
|
||||
managementConfiguration: ""
|
||||
manifest: Manifest_ContextBaz
|
||||
|
||||
managementConfiguration: ""
|
||||
manifest: Manifest_ContextFoo
|
||||
|
||||
|
@ -1,9 +1,23 @@
|
||||
managementConfiguration: ""
|
||||
manifest: Manifest_ContextBar
|
||||
Error: accepts at most 1 arg(s), received 2
|
||||
Usage:
|
||||
get-context CONTEXT_NAME [flags]
|
||||
|
||||
managementConfiguration: ""
|
||||
manifest: Manifest_ContextBaz
|
||||
Aliases:
|
||||
get-context, get-contexts
|
||||
|
||||
managementConfiguration: ""
|
||||
manifest: Manifest_ContextFoo
|
||||
Examples:
|
||||
|
||||
# List all contexts
|
||||
airshipctl config get-contexts
|
||||
|
||||
# Display the current context
|
||||
airshipctl config get-context --current
|
||||
|
||||
# Display a specific context
|
||||
airshipctl config get-context exampleContext
|
||||
|
||||
|
||||
Flags:
|
||||
--current get the current context
|
||||
-h, --help help for get-context
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
Error: missing configuration: context with name 'contextMissing'
|
||||
Usage:
|
||||
get-context [NAME] [flags]
|
||||
get-context CONTEXT_NAME [flags]
|
||||
|
||||
Aliases:
|
||||
get-context, get-contexts
|
||||
|
@ -8,7 +8,7 @@ Display information about contexts such as associated manifests, users, and clus
|
||||
|
||||
|
||||
```
|
||||
airshipctl config get-context [NAME] [flags]
|
||||
airshipctl config get-context CONTEXT_NAME [flags]
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
Loading…
Reference in New Issue
Block a user