fix(cli): avoid panicking when no argument is given (#2024)

This commit is contained in:
L. Yeung 2022-04-03 13:44:05 +08:00 committed by GitHub
parent b61ec064dd
commit 961c4db31b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -30,6 +30,10 @@ See the documentation to initialize your shell: https://ohmyposh.dev/docs/prompt
},
Args: cobra.OnlyValidArgs,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
_ = cmd.Help()
return
}
runInit(args[0])
},
}

View file

@ -45,6 +45,10 @@ var printCmd = &cobra.Command{
},
Args: cobra.OnlyValidArgs,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
_ = cmd.Help()
return
}
env := &environment.ShellEnvironment{
Version: cliVersion,
CmdFlags: &environment.Flags{