Skip to content

Commit

Permalink
Fix root command help printing (#1524)
Browse files Browse the repository at this point in the history
## Description

This hotfixes the root command to properly display help information when
a bad command is entered

## Related Issue

Fixes #N/A

## Type of change

- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

## Checklist before merging

- [X] Test, docs, adr added or updated as needed
- [X] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed
  • Loading branch information
Racer159 committed Mar 31, 2023
1 parent 9a7cd42 commit e8cc675
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,17 @@ var rootCmd = &cobra.Command{
Long: lang.RootCmdLong,
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
zarfLogo := message.GetLogo()
_, _ = fmt.Fprintln(os.Stderr, zarfLogo)
cmd.Help()

if len(args) > 0 {
pterm.Println()
if strings.Contains(args[0], config.ZarfPackagePrefix) || strings.Contains(args[0], "zarf-init") {
pterm.FgYellow.Printfln(lang.RootCmdDeprecatedDeploy, args[0])
pterm.FgYellow.Printfln("\n"+lang.RootCmdDeprecatedDeploy, args[0])
}
if args[0] == config.ZarfYAML {
pterm.FgYellow.Printfln(lang.RootCmdDeprecatedCreate)
pterm.FgYellow.Printfln("\n" + lang.RootCmdDeprecatedCreate)
}
} else {
zarfLogo := message.GetLogo()
_, _ = fmt.Fprintln(os.Stderr, zarfLogo)
cmd.Help()
}
},
}
Expand Down

0 comments on commit e8cc675

Please sign in to comment.