Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: condition to display help interactive menu #724

Merged
merged 7 commits into from
Oct 19, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,19 @@ var RootCmd = &cobra.Command{
Use: "atmos",
Short: "Universal Tool for DevOps and Cloud Automation",
Long: `Atmos is a universal tool for DevOps and cloud automation used for provisioning, managing and orchestrating workflows across various toolchains`,
PreRun: func(cmd *cobra.Command, args []string) {
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// Determine if the command is a help command or if the help flag is set
isHelpCommand := cmd.Name() == "help"
helpFlag, _ := cmd.Flags().GetBool("help")
aknysh marked this conversation as resolved.
Show resolved Hide resolved

if isHelpCommand || helpFlag {
// Do not silence usage or errors when help is invoked
cmd.SilenceUsage = false
cmd.SilenceErrors = false
} else {
cmd.SilenceUsage = true
cmd.SilenceErrors = true
}
aknysh marked this conversation as resolved.
Show resolved Hide resolved
},
Run: func(cmd *cobra.Command, args []string) {
// Check Atmos configuration
Expand Down