Skip to content

Commit

Permalink
fix(cli): panic on no args
Browse files Browse the repository at this point in the history
  • Loading branch information
sh0rez committed Mar 10, 2020
1 parent c5aed1e commit 9a106cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cmd/tk/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func envSetCmd() *cli.Command {
cmd := &cli.Command{
Use: "set",
Short: "update properties of an environment",
Args: cli.ArgsExact(1),
Args: workflowArgs,
Predictors: complete.Flags{
"server-from-context": kubectlContexts,
},
Expand Down Expand Up @@ -175,6 +175,7 @@ func envRemoveCmd() *cli.Command {
Use: "remove <path>",
Aliases: []string{"rm"},
Short: "delete an environment",
Args: workflowArgs,
Run: func(cmd *cli.Command, args []string) error {
for _, arg := range args {
path, err := filepath.Abs(arg)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ func ArgsAny() Arguments {
}
}

// PredictAny predicts anything (usually files and directories)
// PredictAny predicts any files/directories
func PredictAny() complete.Predictor {
return complete.PredictAnything
return complete.PredictFiles("*")
}

// ValidateAny always approves
Expand Down
3 changes: 3 additions & 0 deletions pkg/cli/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func (c *Command) Execute() error {
}

// validate args
if c.Args == nil {
c.Args = ArgsAny()
}
if err := c.Args.Validate(c.Flags().Args()); err != nil {
return c.help(err)
}
Expand Down

0 comments on commit 9a106cd

Please sign in to comment.