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

Merge atmos specific and terraform help documentation #857

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f0b7b98
Merge atmos specific and terraform help documentation
samtholiya Dec 14, 2024
922ba49
Merge branch 'main' into feature/dev-2821-atmos-terraform-help-should…
samtholiya Dec 16, 2024
437e1d4
Add help for terraform
samtholiya Dec 17, 2024
87fd2fd
Updated help content
samtholiya Dec 23, 2024
d7cabbd
Merge branch 'main' of https://github.com/cloudposse/atmos into featu…
samtholiya Dec 23, 2024
95304aa
test fix for auto approve
samtholiya Dec 23, 2024
0f3f84e
Update message for invalid command
samtholiya Dec 24, 2024
c719d86
remove old help code
samtholiya Dec 24, 2024
891e5d2
Merge branch 'main' into feature/dev-2821-atmos-terraform-help-should…
samtholiya Dec 24, 2024
fba6986
testing if auto-approve should be with two -
samtholiya Dec 24, 2024
48fee23
Merge branch 'feature/dev-2821-atmos-terraform-help-should-also-show-…
samtholiya Dec 24, 2024
636fb16
Merge branch 'main' into feature/dev-2821-atmos-terraform-help-should…
samtholiya Dec 26, 2024
51bbb79
check error after executing old usage func
samtholiya Dec 26, 2024
7765e3f
Merge branch 'feature/dev-2821-atmos-terraform-help-should-also-show-…
samtholiya Dec 26, 2024
d0351a8
Merge branch 'main' into feature/dev-2821-atmos-terraform-help-should…
samtholiya Dec 27, 2024
0491db4
Merge branch 'main' into feature/dev-2821-atmos-terraform-help-should…
samtholiya Dec 30, 2024
ce5bef1
rebase help.go
samtholiya Dec 31, 2024
1d8fe0e
Fix terraform subcommand help
samtholiya Dec 31, 2024
a8d6345
Remove unwanted setHelpFunc
samtholiya Dec 31, 2024
ed8b9f8
terraform,helmfile empty sub command should redirect to help
samtholiya Dec 31, 2024
18a6d96
check errors for usage and help
samtholiya Dec 31, 2024
40b4dd3
Added space in between Native commands
samtholiya Dec 31, 2024
80c4b8a
Removed unwanted code
samtholiya Jan 2, 2025
ea2732f
Removed unwanted help check
samtholiya Jan 5, 2025
9184a73
Merge branch 'main' into feature/dev-2821-atmos-terraform-help-should…
samtholiya Jan 5, 2025
5766d45
Fix atmos help
samtholiya Jan 5, 2025
18aaa77
Help should be in stdout terminal
samtholiya Jan 5, 2025
58cbac8
Merge branch 'main' into feature/dev-2821-atmos-terraform-help-should…
samtholiya Jan 5, 2025
1e865b5
Merge branch 'main' into feature/dev-2821-atmos-terraform-help-should…
aknysh Jan 7, 2025
e1b0146
updates
aknysh Jan 7, 2025
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
Prev Previous commit
Next Next commit
Remove unwanted setHelpFunc
  • Loading branch information
samtholiya committed Dec 31, 2024
commit a8d6345402c5efbbd79a86f1b28f7e1f24666161
5 changes: 0 additions & 5 deletions cmd/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,6 @@ func CheckForAtmosUpdateAndPrintMessage(atmosConfig schema.AtmosConfiguration) {
}
}

func customHelpMessageToUpgradeToAtmosLatestRelease(cmd *cobra.Command, args []string) {
originalHelpFunc(cmd, args)
CheckForAtmosUpdateAndPrintMessage(atmosConfig)
}

// Check Atmos is version command
func isVersionCommand() bool {
return len(os.Args) > 1 && os.Args[1] == "version"
Expand Down
11 changes: 0 additions & 11 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ import (

var atmosConfig schema.AtmosConfiguration

// originalHelpFunc holds Cobra's original help function to avoid recursion.
var originalHelpFunc func(*cobra.Command, []string)

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "atmos",
Expand Down Expand Up @@ -96,14 +93,6 @@ func Execute() error {
}
}

// Save the original help function to prevent infinite recursion when overriding it.
// This allows us to call the original help functionality within our custom help function.
originalHelpFunc = RootCmd.HelpFunc()

// Override the help function with a custom one that adds an upgrade message after displaying help.
// This custom help function will call the original help function and then display the bordered message.
RootCmd.SetHelpFunc(customHelpMessageToUpgradeToAtmosLatestRelease)

// If CLI configuration was found, process its custom commands and command aliases
if initErr == nil {
err = processCustomCommands(atmosConfig, atmosConfig.Commands, RootCmd, true)
Expand Down
46 changes: 24 additions & 22 deletions cmd/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,31 @@ func terraformRun(cmd *cobra.Command, actualCmd *cobra.Command, args []string) e
return fmt.Errorf("unknown command %q for %q", args[0], cmd.CommandPath())
}
}
// Check for the latest Atmos release on GitHub and print update message
template := templates.GenerateFromBaseTemplate(actualCmd.Use, []templates.HelpTemplateSections{
templates.LongDescription,
templates.Usage,
templates.Aliases,
templates.Examples,
templates.AvailableCommands,
templates.Flags,
templates.GlobalFlags,
templates.NativeCommands,
templates.DoubleDashHelp,
templates.Footer,
})
// check if this is terraform --help command. TODO: check if this is the best way to do
if cmd == actualCmd {
template := templates.GenerateFromBaseTemplate(actualCmd.Use, []templates.HelpTemplateSections{
templates.LongDescription,
templates.Usage,
templates.Aliases,
templates.Examples,
templates.AvailableCommands,
templates.Flags,
templates.GlobalFlags,
templates.NativeCommands,
templates.DoubleDashHelp,
templates.Footer,
})
actualCmd.SetUsageTemplate(template)
cc.Init(&cc.Config{
RootCmd: actualCmd,
Headings: cc.HiCyan + cc.Bold + cc.Underline,
Commands: cc.HiGreen + cc.Bold,
Example: cc.Italic,
ExecName: cc.Bold,
Flags: cc.Bold,
})

actualCmd.SetUsageTemplate(template)
cc.Init(&cc.Config{
RootCmd: actualCmd,
Headings: cc.HiCyan + cc.Bold + cc.Underline,
Commands: cc.HiGreen + cc.Bold,
Example: cc.Italic,
ExecName: cc.Bold,
Flags: cc.Bold,
})
}

actualCmd.Help()
return nil
Expand Down
1 change: 1 addition & 0 deletions internal/tui/templates/base_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Global Flags:
{{.CommandPath}} [command]{{end}}`
case DoubleDashHelp:
return fmt.Sprintf(`

The '--' (double-dash) can be used to signify the end of Atmos-specific options
and the beginning of additional native arguments and flags for the specific command being run.

Expand Down
1 change: 1 addition & 0 deletions internal/tui/templates/templater.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func SetCustomUsageFunc(cmd *cobra.Command) error {
Flags,
GlobalFlags,
AdditionalHelpTopics,
DoubleDashHelp,
Footer,
}),
}
Expand Down
Loading