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

This commit is contained in:
L. Yeung
2022-04-03 07:44:05 +02:00
committed by GitHub
parent b61ec064dd
commit 961c4db31b
2 changed files with 8 additions and 0 deletions
+4
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])
},
}
+4
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{