From 01bcd67769c16aa5228d1b2a6d89b0a1f72807e2 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Mon, 20 Jan 2025 23:11:09 +0100 Subject: [PATCH 01/64] fix help for 'atmos about non-existent' --- cmd/about.go | 11 +- ...tCLICommands_atmos_--help#01.stderr.golden | 0 ...tCLICommands_atmos_--help#01.stdout.golden | 62 ++++++++ ...ICommands_atmos_about_--help.stderr.golden | 0 ...ICommands_atmos_about_--help.stdout.golden | 36 +++++ ...nds_atmos_about_non-existent.stderr.golden | 2 + ...nds_atmos_about_non-existent.stdout.golden | 3 + ...stCLICommands_atmos_atlantis.stderr.golden | 2 + ...stCLICommands_atmos_atlantis.stdout.golden | 4 + ...mmands_atmos_atlantis_--help.stderr.golden | 0 ...mmands_atmos_atlantis_--help.stdout.golden | 44 ++++++ ...ands_atmos_atlantis_generate.stderr.golden | 2 + ...ands_atmos_atlantis_generate.stdout.golden | 4 + ...mos_atlantis_generate_--help.stderr.golden | 0 ...mos_atlantis_generate_--help.stdout.golden | 55 +++++++ ...atmos_atlantis_generate_help.stderr.golden | 0 ...atmos_atlantis_generate_help.stdout.golden | 55 +++++++ ...tlantis_generate_repo-config.stderr.golden | 0 ...tlantis_generate_repo-config.stdout.golden | 18 +++ ..._generate_repo-config_--help.stderr.golden | 0 ..._generate_repo-config_--help.stdout.golden | 139 ++++++++++++++++++ ...is_generate_repo-config_help.stderr.golden | 0 ...is_generate_repo-config_help.stdout.golden | 139 ++++++++++++++++++ ...ate_repo-config_non-existant.stderr.golden | 2 + ...ate_repo-config_non-existant.stdout.golden | 3 + ...Commands_atmos_atlantis_help.stderr.golden | 0 ...Commands_atmos_atlantis_help.stdout.golden | 44 ++++++ ...stCLICommands_atmos_helmfile.stderr.golden | 2 + ...stCLICommands_atmos_helmfile.stdout.golden | 8 + ...mmands_atmos_helmfile_--help.stderr.golden | 0 ...mmands_atmos_helmfile_--help.stdout.golden | 55 +++++++ ...ommands_atmos_helmfile_apply.stderr.golden | 1 + ...ommands_atmos_helmfile_apply.stdout.golden | 0 ..._atmos_helmfile_apply_--help.stderr.golden | 0 ..._atmos_helmfile_apply_--help.stdout.golden | 39 +++++ ...ds_atmos_helmfile_apply_help.stderr.golden | 0 ...ds_atmos_helmfile_apply_help.stdout.golden | 39 +++++ ..._helmfile_apply_non-existant.stderr.golden | 0 ..._helmfile_apply_non-existant.stdout.golden | 18 +++ ...Commands_atmos_helmfile_help.stderr.golden | 0 ...Commands_atmos_helmfile_help.stdout.golden | 55 +++++++ ..._atmos_helmfile_non-existant.stderr.golden | 2 + ..._atmos_helmfile_non-existant.stdout.golden | 8 + ...ICommands_atmos_non-existent.stderr.golden | 5 +- ...ICommands_atmos_non-existent.stdout.golden | 21 +++ ...tCLICommands_atmos_terraform.stderr.golden | 2 + ...tCLICommands_atmos_terraform.stdout.golden | 34 +++++ ...atmos_terraform_apply_--help.stderr.golden | 0 ...atmos_terraform_apply_--help.stdout.golden | 59 ++++++++ ...s_atmos_terraform_apply_help.stderr.golden | 0 ...s_atmos_terraform_apply_help.stdout.golden | 59 ++++++++ ...ommands_atmos_terraform_help.stderr.golden | 0 ...ommands_atmos_terraform_help.stdout.golden | 94 ++++++++++++ ...atmos_terraform_non-existent.stderr.golden | 2 + ...atmos_terraform_non-existent.stdout.golden | 35 +++++ ...on-existent_in_non_workspace.stderr.golden | 0 ...on-existent_in_non_workspace.stdout.golden | 18 +++ ...an_non-existent_in_workspace.stderr.golden | 1 + ...an_non-existent_in_workspace.stdout.golden | 0 tests/test-cases/core.yaml | 14 -- tests/test-cases/help-and-usage.yaml | 79 +++++++++- 61 files changed, 1250 insertions(+), 25 deletions(-) create mode 100644 tests/snapshots/TestCLICommands_atmos_--help#01.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_--help#01.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_about_--help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_about_non-existent.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_--help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_--help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_apply.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_apply_non-existant.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_apply_non-existant.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_non_workspace.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_non_workspace.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stdout.golden diff --git a/cmd/about.go b/cmd/about.go index 5f15a2bbd..b2cb3a278 100644 --- a/cmd/about.go +++ b/cmd/about.go @@ -14,13 +14,10 @@ var aboutMarkdown string // aboutCmd represents the about command var aboutCmd = &cobra.Command{ - Use: "about", - Short: "Learn about Atmos", - Long: `Display information about Atmos, its features, and benefits.`, - Args: cobra.NoArgs, - DisableSuggestions: true, - SilenceUsage: true, - SilenceErrors: true, + Use: "about", + Short: "Learn about Atmos", + Long: `Display information about Atmos, its features, and benefits.`, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { renderer, err := glamour.NewTermRenderer( glamour.WithAutoStyle(), diff --git a/tests/snapshots/TestCLICommands_atmos_--help#01.stderr.golden b/tests/snapshots/TestCLICommands_atmos_--help#01.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_--help#01.stdout.golden b/tests/snapshots/TestCLICommands_atmos_--help#01.stdout.golden new file mode 100644 index 000000000..af98afaad --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_--help#01.stdout.golden @@ -0,0 +1,62 @@ + + +Usage: + + atmos [flags] + atmos [sub-command] [flags] + + +Available Commands: + + about Learn about Atmos + atlantis Generate and manage Atlantis configurations + aws Run AWS-specific commands for interacting with cloud resources + completion Generate autocompletion scripts for Bash, Zsh, Fish, and PowerShell + describe Show details about Atmos configurations and components + docs Open Atmos documentation or display component-specific docs + helmfile Manage Helmfile-based Kubernetes deployments + help Display help information for Atmos commands + list List available stacks and components + pro Access premium features integrated with app.cloudposse.com + support Show Atmos support options + terraform Execute Terraform commands (e.g., plan, apply, destroy) using Atmos stack configurations + validate Validate configurations against OPA policies and JSON schemas + vendor Manage external dependencies for components or stacks + version Display the version of Atmos you are running and check for updates + workflow Run predefined tasks using workflows + +SubCommand Aliases: + + hf Alias of "atmos helmfile" command + tf Alias of "atmos terraform" command + + +Flags: + + -h, --help help for atmos (default "false") + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + +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. + +Example: + atmos [subcommand] -s -- + + +Use "atmos [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_about_--help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_about_--help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden new file mode 100644 index 000000000..789ed6cf9 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden @@ -0,0 +1,36 @@ + + +Usage: + + atmos about [flags] + + +Flags: + + -h, --help help for about (default "false") + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + +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. + +Example: + atmos about -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden new file mode 100644 index 000000000..961c3bb7b --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden @@ -0,0 +1,2 @@ +Error: Unknown command "non-existent" for "atmos about" + diff --git a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stdout.golden b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stdout.golden new file mode 100644 index 000000000..a8a285014 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stdout.golden @@ -0,0 +1,3 @@ +No valid subcommands found + +Run 'atmos about --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden new file mode 100644 index 000000000..b0f3d7c05 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden @@ -0,0 +1,2 @@ +Error: Unknown command: "atmos atlantis" + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis.stdout.golden new file mode 100644 index 000000000..8ea0d8b15 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis.stdout.golden @@ -0,0 +1,4 @@ +Valid subcommands are: + generate + +Run 'atmos atlantis --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden new file mode 100644 index 000000000..d557b25c4 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden @@ -0,0 +1,44 @@ + + +Usage: + + atmos atlantis [sub-command] [flags] + + +Available Commands: + + generate Generate Atlantis configuration files + + +Flags: + + -h, --help help for atlantis (default "false") + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + +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. + +Example: + atmos atlantis [subcommand] -s -- + + +Use "atmos atlantis [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden new file mode 100644 index 000000000..fc2b39593 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden @@ -0,0 +1,2 @@ +Error: Unknown command: "atmos atlantis generate" + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stdout.golden new file mode 100644 index 000000000..51dd84584 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stdout.golden @@ -0,0 +1,4 @@ +Valid subcommands are: + repo-config + +Run 'atmos atlantis generate --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden new file mode 100644 index 000000000..68a1188ec --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden @@ -0,0 +1,55 @@ + + +Usage: + + atmos atlantis generate [sub-command] [flags] + + +Available Commands: + + repo-config Generate repository configuration for Atlantis + + +Flags: + + --clone-target-ref Clone the target reference with which to compare + the current branch: atmos atlantis generate + repo-config --affected-only=true + --clone-target-ref=true + The flag is only used when '--affected-only=true' + If set to 'false' (default), the target reference + will be checked out instead + This requires that the target reference is already + cloned by Git, and the information about it exists + in the '.git' directory (default "false") + + -h, --help help for generate (default "false") + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + +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. + +Example: + atmos atlantis generate [subcommand] -s -- + + +Use "atmos atlantis generate [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden new file mode 100644 index 000000000..68a1188ec --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden @@ -0,0 +1,55 @@ + + +Usage: + + atmos atlantis generate [sub-command] [flags] + + +Available Commands: + + repo-config Generate repository configuration for Atlantis + + +Flags: + + --clone-target-ref Clone the target reference with which to compare + the current branch: atmos atlantis generate + repo-config --affected-only=true + --clone-target-ref=true + The flag is only used when '--affected-only=true' + If set to 'false' (default), the target reference + will be checked out instead + This requires that the target reference is already + cloned by Git, and the information about it exists + in the '.git' directory (default "false") + + -h, --help help for generate (default "false") + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + +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. + +Example: + atmos atlantis generate [subcommand] -s -- + + +Use "atmos atlantis generate [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config.stdout.golden new file mode 100644 index 000000000..219bb02fb --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config.stdout.golden @@ -0,0 +1,18 @@ + +atmos.yaml CLI config file specifies the directory for Atmos stacks as stacks, +but the directory does not exist. + +To configure and start using Atmos, refer to the following documents: + +Atmos CLI Configuration: +https://atmos.tools/cli/configuration + +Atmos Components: +https://atmos.tools/core-concepts/components + +Atmos Stacks: +https://atmos.tools/core-concepts/stacks + +Quick Start: +https://atmos.tools/quick-start + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden new file mode 100644 index 000000000..6df1042ce --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden @@ -0,0 +1,139 @@ + + +Usage: + + atmos atlantis generate repo-config [flags] + + +Flags: + + --affected-only Generate Atlantis projects only for the + Atmos components changed between two Git + commits. + atmos atlantis generate repo-config + --affected-only=true (default "false") + + --components string Generate Atlantis projects for the + specified components only (comma-separated + values). + atmos atlantis generate repo-config + --config-template + --project-template + --components , + + --config-template string atmos atlantis generate repo-config + --config-template config-1 + --project-template project-1 + + -h, --help help for repo-config (default "false") + + --output-path string atmos atlantis generate repo-config + --output-path ./atlantis.yaml + --config-template config-1 + --project-template project-1 + + --project-template string atmos atlantis generate repo-config + --config-template config-1 + --project-template project-1 + + --ref string Git reference with which to compare the + current branch: atmos atlantis generate + repo-config --affected-only=true --ref + refs/heads/main. Refer to + https://git-scm.com/book/en/v2/Git-Internals-Git-References + for more details + + --repo-path string Filesystem path to the already cloned + target repository with which to compare the + current branch: atmos atlantis generate + repo-config --affected-only=true + --repo-path + + --sha string Git commit SHA with which to compare the + current branch: atmos atlantis generate + repo-config --affected-only=true --sha + 3a5eafeab90426bd82bf5899896b28cc0bab3073 + + --ssh-key string Path to PEM-encoded private key to clone + private repos using SSH: atmos atlantis + generate repo-config --affected-only=true + --ssh-key + + --ssh-key-password string Encryption password for the PEM-encoded + private key if the key contains a + password-encrypted PEM block: atmos + atlantis generate repo-config + --affected-only=true --ssh-key + --ssh-key-password + + + --stacks string Generate Atlantis projects for the + specified stacks only (comma-separated + values). + atmos atlantis generate repo-config + --config-template + --project-template + --stacks , + The filter can contain the names of the + top-level stack manifests and the logical + stack names (derived from the context vars) + atmos atlantis generate repo-config + --config-template + --project-template + --stacks + orgs/cp/tenant1/staging/us-east-2,orgs/cp/tenant2/dev/us-east-2 + atmos atlantis generate repo-config + --config-template + --project-template + --stacks + tenant1-ue2-staging,tenant1-ue2-prod + atmos atlantis generate repo-config + --config-template + --project-template + --stacks + orgs/cp/tenant1/staging/us-east-2,tenant1-ue2-prod + + --verbose Print more detailed output when cloning and + checking out the Git repository: atmos + atlantis generate repo-config + --affected-only=true --verbose=true + (default "false") + + +Global Flags: + + --clone-target-ref Clone the target reference with which to + compare the current branch: atmos atlantis + generate repo-config --affected-only=true + --clone-target-ref=true + The flag is only used when + '--affected-only=true' + If set to 'false' (default), the target + reference will be checked out instead + This requires that the target reference is + already cloned by Git, and the information + about it exists in the '.git' directory + (default "false") + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + +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. + +Example: + atmos atlantis generate repo-config -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden new file mode 100644 index 000000000..6df1042ce --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden @@ -0,0 +1,139 @@ + + +Usage: + + atmos atlantis generate repo-config [flags] + + +Flags: + + --affected-only Generate Atlantis projects only for the + Atmos components changed between two Git + commits. + atmos atlantis generate repo-config + --affected-only=true (default "false") + + --components string Generate Atlantis projects for the + specified components only (comma-separated + values). + atmos atlantis generate repo-config + --config-template + --project-template + --components , + + --config-template string atmos atlantis generate repo-config + --config-template config-1 + --project-template project-1 + + -h, --help help for repo-config (default "false") + + --output-path string atmos atlantis generate repo-config + --output-path ./atlantis.yaml + --config-template config-1 + --project-template project-1 + + --project-template string atmos atlantis generate repo-config + --config-template config-1 + --project-template project-1 + + --ref string Git reference with which to compare the + current branch: atmos atlantis generate + repo-config --affected-only=true --ref + refs/heads/main. Refer to + https://git-scm.com/book/en/v2/Git-Internals-Git-References + for more details + + --repo-path string Filesystem path to the already cloned + target repository with which to compare the + current branch: atmos atlantis generate + repo-config --affected-only=true + --repo-path + + --sha string Git commit SHA with which to compare the + current branch: atmos atlantis generate + repo-config --affected-only=true --sha + 3a5eafeab90426bd82bf5899896b28cc0bab3073 + + --ssh-key string Path to PEM-encoded private key to clone + private repos using SSH: atmos atlantis + generate repo-config --affected-only=true + --ssh-key + + --ssh-key-password string Encryption password for the PEM-encoded + private key if the key contains a + password-encrypted PEM block: atmos + atlantis generate repo-config + --affected-only=true --ssh-key + --ssh-key-password + + + --stacks string Generate Atlantis projects for the + specified stacks only (comma-separated + values). + atmos atlantis generate repo-config + --config-template + --project-template + --stacks , + The filter can contain the names of the + top-level stack manifests and the logical + stack names (derived from the context vars) + atmos atlantis generate repo-config + --config-template + --project-template + --stacks + orgs/cp/tenant1/staging/us-east-2,orgs/cp/tenant2/dev/us-east-2 + atmos atlantis generate repo-config + --config-template + --project-template + --stacks + tenant1-ue2-staging,tenant1-ue2-prod + atmos atlantis generate repo-config + --config-template + --project-template + --stacks + orgs/cp/tenant1/staging/us-east-2,tenant1-ue2-prod + + --verbose Print more detailed output when cloning and + checking out the Git repository: atmos + atlantis generate repo-config + --affected-only=true --verbose=true + (default "false") + + +Global Flags: + + --clone-target-ref Clone the target reference with which to + compare the current branch: atmos atlantis + generate repo-config --affected-only=true + --clone-target-ref=true + The flag is only used when + '--affected-only=true' + If set to 'false' (default), the target + reference will be checked out instead + This requires that the target reference is + already cloned by Git, and the information + about it exists in the '.git' directory + (default "false") + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + +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. + +Example: + atmos atlantis generate repo-config -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden new file mode 100644 index 000000000..9a5366b58 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden @@ -0,0 +1,2 @@ +Error: Unknown command "non-existant" for "atmos atlantis generate repo-config" + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stdout.golden new file mode 100644 index 000000000..418a741ad --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stdout.golden @@ -0,0 +1,3 @@ +No valid subcommands found + +Run 'atmos atlantis generate repo-config --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden new file mode 100644 index 000000000..d557b25c4 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden @@ -0,0 +1,44 @@ + + +Usage: + + atmos atlantis [sub-command] [flags] + + +Available Commands: + + generate Generate Atlantis configuration files + + +Flags: + + -h, --help help for atlantis (default "false") + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + +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. + +Example: + atmos atlantis [subcommand] -s -- + + +Use "atmos atlantis [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden new file mode 100644 index 000000000..9334d903c --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden @@ -0,0 +1,2 @@ +Error: Unknown command: "atmos helmfile" + diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile.stdout.golden new file mode 100644 index 000000000..38666a97e --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_helmfile.stdout.golden @@ -0,0 +1,8 @@ +Valid subcommands are: + apply + destroy + diff + generate + sync + +Run 'atmos helmfile --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden new file mode 100644 index 000000000..37158506a --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden @@ -0,0 +1,55 @@ + + +Usage: + + atmos helmfile [sub-command] [flags] + +Aliases: + + helmfile, hf + + +Available Commands: + + apply Apply changes to align the actual state of Helm releases with the desired state. + destroy Destroy the Helm releases for the specified stack. + diff Show differences between the desired and actual state of Helm releases. + generate Generate configurations for Helmfile components + sync Synchronize the state of Helm releases with the desired state without making changes. + + +Flags: + + -h, --help help for helmfile (default "false") + + -s, --stack string atmos helmfile -s + + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + +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. + +Example: + atmos helmfile [subcommand] -s -- + + +Use "atmos helmfile [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden new file mode 100644 index 000000000..4a566d55e --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden @@ -0,0 +1 @@ +'stack' is required. Usage: atmos helmfile -s diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stdout.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden new file mode 100644 index 000000000..bb3fe72a5 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden @@ -0,0 +1,39 @@ + + +Usage: + + atmos helmfile apply [flags] + + +Flags: + + -h, --help help for apply (default "false") + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + + -s, --stack string atmos helmfile + -s + +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. + +Example: + atmos helmfile apply -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden new file mode 100644 index 000000000..bb3fe72a5 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden @@ -0,0 +1,39 @@ + + +Usage: + + atmos helmfile apply [flags] + + +Flags: + + -h, --help help for apply (default "false") + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + + -s, --stack string atmos helmfile + -s + +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. + +Example: + atmos helmfile apply -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_non-existant.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_non-existant.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_non-existant.stdout.golden new file mode 100644 index 000000000..219bb02fb --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_non-existant.stdout.golden @@ -0,0 +1,18 @@ + +atmos.yaml CLI config file specifies the directory for Atmos stacks as stacks, +but the directory does not exist. + +To configure and start using Atmos, refer to the following documents: + +Atmos CLI Configuration: +https://atmos.tools/cli/configuration + +Atmos Components: +https://atmos.tools/core-concepts/components + +Atmos Stacks: +https://atmos.tools/core-concepts/stacks + +Quick Start: +https://atmos.tools/quick-start + diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden new file mode 100644 index 000000000..37158506a --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden @@ -0,0 +1,55 @@ + + +Usage: + + atmos helmfile [sub-command] [flags] + +Aliases: + + helmfile, hf + + +Available Commands: + + apply Apply changes to align the actual state of Helm releases with the desired state. + destroy Destroy the Helm releases for the specified stack. + diff Show differences between the desired and actual state of Helm releases. + generate Generate configurations for Helmfile components + sync Synchronize the state of Helm releases with the desired state without making changes. + + +Flags: + + -h, --help help for helmfile (default "false") + + -s, --stack string atmos helmfile -s + + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + +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. + +Example: + atmos helmfile [subcommand] -s -- + + +Use "atmos helmfile [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden new file mode 100644 index 000000000..a1ba4f1a1 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden @@ -0,0 +1,2 @@ +Error: Unknown command "non-existant" for "atmos helmfile" + diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stdout.golden new file mode 100644 index 000000000..38666a97e --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stdout.golden @@ -0,0 +1,8 @@ +Valid subcommands are: + apply + destroy + diff + generate + sync + +Run 'atmos helmfile --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden index cdf2b3ad8..76adc7c0e 100644 --- a/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden @@ -1,3 +1,2 @@ -Error: unknown command "non-existent" for "atmos" -Run 'atmos --help' for usage. -unknown command "non-existent" for "atmos" +Error: Unknown command "non-existent" for "atmos" + diff --git a/tests/snapshots/TestCLICommands_atmos_non-existent.stdout.golden b/tests/snapshots/TestCLICommands_atmos_non-existent.stdout.golden index e69de29bb..5d3c0b07f 100644 --- a/tests/snapshots/TestCLICommands_atmos_non-existent.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_non-existent.stdout.golden @@ -0,0 +1,21 @@ +Valid subcommands are: + about + atlantis + aws + completion + describe + docs + helmfile + help + list + pro + show + support + terraform + tf + validate + vendor + version + workflow + +Run 'atmos --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden new file mode 100644 index 000000000..1b53ce83a --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden @@ -0,0 +1,2 @@ +Error: Unknown command: "atmos terraform" + diff --git a/tests/snapshots/TestCLICommands_atmos_terraform.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform.stdout.golden new file mode 100644 index 000000000..e2de0a1d0 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform.stdout.golden @@ -0,0 +1,34 @@ +Valid subcommands are: + apply + clean + console + deploy + destroy + fmt + force-unlock + generate + get + graph + import + init + login + logout + metadata + modules + output + plan + providers + refresh + shell + show + state + taint + test + untaint + validate + varfile + version + workspace + write + +Run 'atmos terraform --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden new file mode 100644 index 000000000..50dac239e --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden @@ -0,0 +1,59 @@ + + +Usage: + + atmos terraform apply [flags] + + +Examples: + +atmos terraform apply -s + + +Flags: + + --from-plan If set atmos will use the previously generated plan + file (default "false") + + -h, --help help for apply (default "false") + + --planfile string Set the plan file to use + + +Global Flags: + + --append-user-agent string Sets the TF_APPEND_USER_AGENT environment + variable to customize the User-Agent + string in Terraform provider requests. + Example: 'Atmos/%s (Cloud Posse; + +https://atmos.tools)'. This flag works + with almost all commands. + + --logs-file string The file to write Atmos logs to. Logs can + be written to any file or any standard + file descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are + Trace, Debug, Info, Warning, Off. If the + log level is set to Off, Atmos will not + log any messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or + any standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + + --skip-init Skip running 'terraform init' before + executing the command (default "false") + + -s, --stack string atmos terraform + -s + +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. + +Example: + atmos terraform apply -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden new file mode 100644 index 000000000..50dac239e --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden @@ -0,0 +1,59 @@ + + +Usage: + + atmos terraform apply [flags] + + +Examples: + +atmos terraform apply -s + + +Flags: + + --from-plan If set atmos will use the previously generated plan + file (default "false") + + -h, --help help for apply (default "false") + + --planfile string Set the plan file to use + + +Global Flags: + + --append-user-agent string Sets the TF_APPEND_USER_AGENT environment + variable to customize the User-Agent + string in Terraform provider requests. + Example: 'Atmos/%s (Cloud Posse; + +https://atmos.tools)'. This flag works + with almost all commands. + + --logs-file string The file to write Atmos logs to. Logs can + be written to any file or any standard + file descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are + Trace, Debug, Info, Warning, Off. If the + log level is set to Off, Atmos will not + log any messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or + any standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + + --skip-init Skip running 'terraform init' before + executing the command (default "false") + + -s, --stack string atmos terraform + -s + +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. + +Example: + atmos terraform apply -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden new file mode 100644 index 000000000..c77745dbc --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -0,0 +1,94 @@ + + +Usage: + + atmos terraform [sub-command] [flags] + +Aliases: + + terraform, tf + + +Available Commands: + + clean Clean up Terraform state and artifacts. + deploy Deploy the specified infrastructure using Terraform + generate Generate Terraform configuration files for Atmos components and stacks. + shell Configure an environment for an Atmos component and start a new shell. + varfile Load variables from a file + write Write variables to a file + +Native terraform Commands: + + apply Apply changes to infrastructure + console Try Terraform expressions at an interactive command prompt + destroy Destroy previously-created infrastructure + fmt Reformat your configuration in the standard style + force-unlock Release a stuck lock on the current workspace + get Install or upgrade remote Terraform modules + graph Generate a Graphviz graph of the steps in an operation + import Import existing infrastructure into Terraform state. + init Prepare your working directory for other commands + login Obtain and save credentials for a remote host + logout Remove locally-stored credentials for a remote host + metadata Metadata related commands + modules Show all declared modules in a working directory + output Show output values from your root module + plan Show changes required by the current configuration + providers Show the providers required for this configuration + refresh Update the state to match remote systems + show Show the current state or a saved plan + state Advanced state management + taint Mark a resource instance as not fully functional + test Execute integration tests for Terraform modules + untaint Remove the 'tainted' state from a resource instance + validate Check whether the configuration is valid + version Show the current Terraform version + workspace Manage Terraform workspaces + + +Flags: + + --append-user-agent string Sets the TF_APPEND_USER_AGENT environment + variable to customize the User-Agent + string in Terraform provider requests. + Example: 'Atmos/%s (Cloud Posse; + +https://atmos.tools)'. This flag works + with almost all commands. + + -h, --help help for terraform (default "false") + + --skip-init Skip running 'terraform init' before + executing the command (default "false") + + -s, --stack string atmos terraform + -s + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + +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. + +Example: + atmos terraform [subcommand] -s -- + + +Use "atmos terraform [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden new file mode 100644 index 000000000..7615a96b2 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden @@ -0,0 +1,2 @@ +Error: Unknown command "non-existent" for "atmos terraform" + diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stdout.golden new file mode 100644 index 000000000..1634bdb72 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stdout.golden @@ -0,0 +1,35 @@ +Valid subcommands are: + apply + clean + console + deploy + destroy + fmt + force-unlock + generate + get + graph + import + init + login + logout + metadata + modules + output + plan + providers + provision + refresh + shell + show + state + taint + test + untaint + validate + varfile + version + workspace + write + +Run 'atmos terraform --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_non_workspace.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_non_workspace.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_non_workspace.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_non_workspace.stdout.golden new file mode 100644 index 000000000..219bb02fb --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_non_workspace.stdout.golden @@ -0,0 +1,18 @@ + +atmos.yaml CLI config file specifies the directory for Atmos stacks as stacks, +but the directory does not exist. + +To configure and start using Atmos, refer to the following documents: + +Atmos CLI Configuration: +https://atmos.tools/cli/configuration + +Atmos Components: +https://atmos.tools/core-concepts/components + +Atmos Stacks: +https://atmos.tools/core-concepts/stacks + +Quick Start: +https://atmos.tools/quick-start + diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden new file mode 100644 index 000000000..817dd5d4f --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden @@ -0,0 +1 @@ +'stack' is required. Usage: atmos terraform -s diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stdout.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test-cases/core.yaml b/tests/test-cases/core.yaml index cdbc9bb7c..d7465bad6 100644 --- a/tests/test-cases/core.yaml +++ b/tests/test-cases/core.yaml @@ -77,17 +77,3 @@ tests: exit_code: 0 stderr: - "^$" - - name: atmos terraform non-existent - enabled: false - snapshot: true - description: "Ensure atmos CLI returns an error for a non-existent command." - workdir: "../" - command: "atmos" - args: - - "terraform" - - "non-existent" - expect: - diff: [] - stderr: - - 'unknown command "non-existent" for "atmos"' - exit_code: 1 diff --git a/tests/test-cases/help-and-usage.yaml b/tests/test-cases/help-and-usage.yaml index 31137ea4c..3670be2d3 100644 --- a/tests/test-cases/help-and-usage.yaml +++ b/tests/test-cases/help-and-usage.yaml @@ -1,6 +1,8 @@ tests: - name: atmos non-existent enabled: true + snapshot: true + diff: [] description: "Ensure atmos CLI returns an error for a non-existent command." workdir: "../" command: "atmos" @@ -12,6 +14,8 @@ tests: exit_code: 1 - name: atmos --help enabled: true + snapshot: true + diff: [] description: "Ensure atmos CLI help command lists available commands." workdir: "./" command: "atmos" @@ -57,6 +61,8 @@ tests: exit_code: 1 - name: atmos terraform enabled: true + snapshot: true + diff: [] description: "Ensure atmos terraform cli shows usage command" workdir: "./" command: "atmos" @@ -73,6 +79,8 @@ tests: exit_code: 1 - name: atmos terraform help enabled: true + snapshot: true + diff: [] description: "Ensure 'atmos terraform help' shows help output" workdir: "./" command: "atmos" @@ -103,6 +111,8 @@ tests: exit_code: 0 - name: atmos terraform apply --help enabled: true + snapshot: true + diff: [] description: "Ensure atmos terraform apply --help shows help output" workdir: "./" command: "atmos" @@ -120,6 +130,8 @@ tests: exit_code: 0 - name: atmos terraform apply help enabled: true + snapshot: true + diff: [] description: "Ensure atmos terraform help shows help output" workdir: "./" command: "atmos" @@ -137,6 +149,8 @@ tests: exit_code: 0 - name: atmos terraform non-existent enabled: true + snapshot: true + diff: [] description: "Ensure atmos terraform CLI returns an error for a non-existent command." workdir: "../" command: "atmos" @@ -149,6 +163,8 @@ tests: exit_code: 1 - name: atmos terraform plan non-existent in non workspace enabled: true + snapshot: true + diff: [] description: "Ensure atmos terraform CLI returns an error for a non-existent command in non existing workspace." workdir: "../" command: "atmos" @@ -163,6 +179,8 @@ tests: exit_code: 1 - name: atmos terraform plan non-existent in workspace enabled: true + snapshot: true + diff: [] description: "Ensure atmos terraform CLI returns an error for a non-existent command in existing workspace." workdir: "../examples/quick-start-simple" command: "atmos" @@ -176,6 +194,8 @@ tests: exit_code: 1 - name: atmos helmfile enabled: true + snapshot: true + diff: [] description: "Should show usage for helmfile" workdir: "../" command: "atmos" @@ -191,6 +211,8 @@ tests: exit_code: 1 - name: atmos helmfile non-existant enabled: true + snapshot: true + diff: [] description: "Should show usage for helmfile and non-existant subcommand" workdir: "../" command: "atmos" @@ -207,6 +229,8 @@ tests: exit_code: 1 - name: atmos helmfile help enabled: true + snapshot: true + diff: [] description: "Should show help for helmfile" workdir: "../" command: "atmos" @@ -221,6 +245,8 @@ tests: exit_code: 0 - name: atmos helmfile --help enabled: true + snapshot: true + diff: [] description: "Should show help for helmfile when using help flag" workdir: "../" command: "atmos" @@ -235,6 +261,8 @@ tests: exit_code: 0 - name: atmos helmfile apply non-existant enabled: true + snapshot: true + diff: [] description: "Should show error in non atmos workspace" workdir: "../" command: "atmos" @@ -249,6 +277,8 @@ tests: exit_code: 1 - name: atmos helmfile apply enabled: true + snapshot: true + diff: [] description: "Should show error in atmos workspace" workdir: "../examples/demo-helmfile" command: "atmos" @@ -261,6 +291,8 @@ tests: exit_code: 1 - name: atmos helmfile apply help enabled: true + snapshot: true + diff: [] description: "Should show help for atmos helmfile apply" workdir: "../" command: "atmos" @@ -275,6 +307,8 @@ tests: exit_code: 0 - name: atmos helmfile apply --help enabled: true + snapshot: true + diff: [] description: "Should show help for atmos helmfile apply --help" workdir: "../" command: "atmos" @@ -289,6 +323,8 @@ tests: exit_code: 0 - name: atmos atlantis enabled: true + snapshot: true + diff: [] description: "Should show usage atmos atlantis" workdir: "../" command: "atmos" @@ -300,6 +336,8 @@ tests: exit_code: 1 - name: atmos atlantis help enabled: true + snapshot: true + diff: [] description: "Should show help 'atmos atlantis help'" workdir: "../" command: "atmos" @@ -313,6 +351,8 @@ tests: exit_code: 0 - name: atmos atlantis --help enabled: true + snapshot: true + diff: [] description: "Should show help 'atmos atlantis --help'" workdir: "../" command: "atmos" @@ -327,6 +367,8 @@ tests: - name: atmos atlantis generate enabled: true + snapshot: true + diff: [] description: "Should show usage atmos atlantis" workdir: "../" command: "atmos" @@ -339,6 +381,8 @@ tests: exit_code: 1 - name: atmos atlantis generate help enabled: true + snapshot: true + diff: [] description: "Should show help 'atmos atlantis generate help'" workdir: "../" command: "atmos" @@ -353,6 +397,8 @@ tests: exit_code: 0 - name: atmos atlantis generate --help enabled: true + snapshot: true + diff: [] description: "Should show help 'atmos atlantis --help'" workdir: "../" command: "atmos" @@ -367,6 +413,8 @@ tests: exit_code: 0 - name: atmos atlantis generate repo-config enabled: true + snapshot: true + diff: [] description: "Should show config missing in non atmos workspace 'atmos atlantis generate repo-config'" workdir: "../" command: "atmos" @@ -383,6 +431,8 @@ tests: exit_code: 1 - name: atmos atlantis generate repo-config help enabled: true + snapshot: true + diff: [] description: "Should show help for 'atmos atlantis generate repo-config help'" workdir: "../" command: "atmos" @@ -401,6 +451,8 @@ tests: exit_code: 0 - name: atmos atlantis generate repo-config --help enabled: true + snapshot: true + diff: [] description: "Should show help for 'atmos atlantis generate repo-config --help'" workdir: "../" command: "atmos" @@ -419,6 +471,8 @@ tests: exit_code: 0 - name: atmos atlantis generate repo-config non-existant enabled: true + snapshot: true + diff: [] description: "Should show usage for 'atmos atlantis generate repo-config non-existant'" workdir: "../" command: "atmos" @@ -470,4 +524,27 @@ tests: - "non-existant" expect: exit_code: 1 - + - name: atmos about non-existent + enabled: true + snapshot: true + diff: [] + description: "'atmos about non-existent' should show expected message" + workdir: "../" + command: atmos + args: + - "about" + - "non-existent" + expect: + exit_code: 1 + - name: atmos about --help + enabled: true + snapshot: true + diff: [] + description: "'atmos about --help' should show help" + workdir: "../" + command: atmos + args: + - "about" + - "--help" + expect: + exit_code: 0 \ No newline at end of file From 0470a32d9e68b2677c6af8c10fae111cb6e795c5 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 21 Jan 2025 20:55:54 +0100 Subject: [PATCH 02/64] Add invalid flag error handler --- cmd/cmd_utils.go | 16 ++++- cmd/root.go | 3 + ...tCLICommands_atmos_--help#01.stdout.golden | 62 ------------------- ...station_-s_dev_--_-no-color.stderr.golden} | 0 ..._station_-s_dev_--_-no-color.stdout.golden | 58 +++++++++++++++++ tests/test-cases/help-and-usage.yaml | 30 +++++++++ 6 files changed, 106 insertions(+), 63 deletions(-) delete mode 100644 tests/snapshots/TestCLICommands_atmos_--help#01.stdout.golden rename tests/snapshots/{TestCLICommands_atmos_--help#01.stderr.golden => TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stderr.golden} (100%) create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stdout.golden diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 66a989d3b..34a63a715 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -554,7 +554,6 @@ func handleHelpRequest(cmd *cobra.Command, args []string) { } func showUsageAndExit(cmd *cobra.Command, args []string) { - var suggestions []string unknownCommand := fmt.Sprintf("Error: Unknown command: %q\n\n", cmd.CommandPath()) @@ -587,6 +586,14 @@ func showUsageAndExit(cmd *cobra.Command, args []string) { os.Exit(1) } +func showFlagUsageAndExit(cmd *cobra.Command, err error) error { + unknownCommand := fmt.Sprintf("Error: %v for command %q\n\n", err.Error(), cmd.CommandPath()) + u.PrintErrorInColor(unknownCommand) + u.PrintMessage(fmt.Sprintf("Run '%s --help' for usage", cmd.CommandPath())) + os.Exit(1) + return nil +} + // getConfigAndStacksInfo gets the func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []string) schema.ConfigAndStacksInfo { // Check Atmos configuration @@ -607,3 +614,10 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin } return info } + +func getDoubleDashExample(commandPath string) string { + return fmt.Sprintf(`%s -s -- + +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.`, commandPath) +} diff --git a/cmd/root.go b/cmd/root.go index 40c0c53ea..621f02e34 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -169,6 +169,9 @@ func initCobraConfig() { styles := boa.DefaultStyles() b := boa.New(boa.WithStyles(styles)) oldUsageFunc := RootCmd.UsageFunc() + RootCmd.SetFlagErrorFunc(func(c *cobra.Command, err error) error { + return showFlagUsageAndExit(c, err) + }) RootCmd.SetUsageFunc(func(c *cobra.Command) error { if c.Use == "atmos" { return b.UsageFunc(c) diff --git a/tests/snapshots/TestCLICommands_atmos_--help#01.stdout.golden b/tests/snapshots/TestCLICommands_atmos_--help#01.stdout.golden deleted file mode 100644 index af98afaad..000000000 --- a/tests/snapshots/TestCLICommands_atmos_--help#01.stdout.golden +++ /dev/null @@ -1,62 +0,0 @@ - - -Usage: - - atmos [flags] - atmos [sub-command] [flags] - - -Available Commands: - - about Learn about Atmos - atlantis Generate and manage Atlantis configurations - aws Run AWS-specific commands for interacting with cloud resources - completion Generate autocompletion scripts for Bash, Zsh, Fish, and PowerShell - describe Show details about Atmos configurations and components - docs Open Atmos documentation or display component-specific docs - helmfile Manage Helmfile-based Kubernetes deployments - help Display help information for Atmos commands - list List available stacks and components - pro Access premium features integrated with app.cloudposse.com - support Show Atmos support options - terraform Execute Terraform commands (e.g., plan, apply, destroy) using Atmos stack configurations - validate Validate configurations against OPA policies and JSON schemas - vendor Manage external dependencies for components or stacks - version Display the version of Atmos you are running and check for updates - workflow Run predefined tasks using workflows - -SubCommand Aliases: - - hf Alias of "atmos helmfile" command - tf Alias of "atmos terraform" command - - -Flags: - - -h, --help help for atmos (default "false") - - --logs-file string The file to write Atmos logs to. Logs can be - written to any file or any standard file - descriptor, including '/dev/stdout', - '/dev/stderr' and '/dev/null' (default - "/dev/stdout") - - --logs-level string Logs level. Supported log levels are Trace, - Debug, Info, Warning, Off. If the log level - is set to Off, Atmos will not log any - messages (default "Info") - - --redirect-stderr string File descriptor to redirect 'stderr' to. - Errors can be redirected to any file or any - standard file descriptor (including - '/dev/null'): atmos - --redirect-stderr /dev/stdout - -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. - -Example: - atmos [subcommand] -s -- - - -Use "atmos [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_--help#01.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stderr.golden similarity index 100% rename from tests/snapshots/TestCLICommands_atmos_--help#01.stderr.golden rename to tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stderr.golden diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stdout.golden new file mode 100644 index 000000000..372c49ded --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stdout.golden @@ -0,0 +1,58 @@ +Initializing the backend... +Initializing provider plugins... +- Reusing previous version of hashicorp/http from the dependency lock file +- Reusing previous version of hashicorp/local from the dependency lock file +- Using previously-installed hashicorp/http v3.4.5 +- Using previously-installed hashicorp/local v2.5.2 + +Terraform has been successfully initialized! +Switched to workspace "dev-station". +data.http.weather: Reading... +data.http.weather: Read complete after 0s [id=https://wttr.in/Stockholm?0&format=&lang=se&u=m] + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + + create + +Terraform will perform the following actions: + + # local_file.cache will be created + + resource "local_file" "cache" { + + content = <<-EOT + Weather report: Stockholm + +  .-.  Light rain +  ( ).  +2(-1) °C +  (___(__)  ↗ 9 km/h +  ‘ ‘ ‘ ‘  5 km +  ‘ ‘ ‘ ‘  0.0 mm + EOT + + content_base64sha256 = (known after apply) + + content_base64sha512 = (known after apply) + + content_md5 = (known after apply) + + content_sha1 = (known after apply) + + content_sha256 = (known after apply) + + content_sha512 = (known after apply) + + directory_permission = "0777" + + file_permission = "0777" + + filename = "cache.dev.txt" + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: + + lang = "se" + + location = "Stockholm" + + stage = "dev" + + units = "m" + + url = "https://wttr.in/Stockholm?0&format=&lang=se&u=m" + + weather = <<-EOT + Weather report: Stockholm + +  .-.  Light rain +  ( ).  +2(-1) °C +  (___(__)  ↗ 9 km/h +  ‘ ‘ ‘ ‘  5 km +  ‘ ‘ ‘ ‘  0.0 mm + EOT diff --git a/tests/test-cases/help-and-usage.yaml b/tests/test-cases/help-and-usage.yaml index 3670be2d3..6a6fb81f8 100644 --- a/tests/test-cases/help-and-usage.yaml +++ b/tests/test-cases/help-and-usage.yaml @@ -546,5 +546,35 @@ tests: args: - "about" - "--help" + expect: + exit_code: 0 + - name: atmos version --check --non-existent + enabled: true + snapshot: true + diff: [] + description: "'atmos version --check --non-existent' should show invalid flag usage" + workdir: "../" + command: atmos + args: + - "version" + - "--check" + - "--non-existent" + expect: + exit_code: 1 + - name: atmos terraform plan station -s dev -- -no-color + enabled: true + snapshot: true + diff: [] + description: "'atmos terraform plan station -s dev -- -no-color' should pass native flags to terraform without errors for flags" + workdir: "../examples/quick-start-simple" + command: atmos + args: + - "terraform" + - "plan" + - "station" + - "-s" + - "dev" + - "--" + - "-no-color" expect: exit_code: 0 \ No newline at end of file From 3d3ebbcb8dc06b06249fb1b6716223929e5b3340 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 21 Jan 2025 21:46:42 +0100 Subject: [PATCH 03/64] Ignore update messages in tests --- tests/test-cases/help-and-usage.yaml | 127 +++++++++++++++++++-------- 1 file changed, 92 insertions(+), 35 deletions(-) diff --git a/tests/test-cases/help-and-usage.yaml b/tests/test-cases/help-and-usage.yaml index 6a6fb81f8..fed7d6dd5 100644 --- a/tests/test-cases/help-and-usage.yaml +++ b/tests/test-cases/help-and-usage.yaml @@ -2,7 +2,6 @@ tests: - name: atmos non-existent enabled: true snapshot: true - diff: [] description: "Ensure atmos CLI returns an error for a non-existent command." workdir: "../" command: "atmos" @@ -15,13 +14,17 @@ tests: - name: atmos --help enabled: true snapshot: true - diff: [] description: "Ensure atmos CLI help command lists available commands." workdir: "./" command: "atmos" args: - "--help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "Usage:" - "Available Commands:" @@ -49,6 +52,7 @@ tests: exit_code: 0 - name: atmos enabled: true + snapshot: true description: "Ensure atmos CLI help command shows atmos config " workdir: "./" command: "atmos" @@ -62,7 +66,6 @@ tests: - name: atmos terraform enabled: true snapshot: true - diff: [] description: "Ensure atmos terraform cli shows usage command" workdir: "./" command: "atmos" @@ -80,7 +83,6 @@ tests: - name: atmos terraform help enabled: true snapshot: true - diff: [] description: "Ensure 'atmos terraform help' shows help output" workdir: "./" command: "atmos" @@ -88,6 +90,11 @@ tests: - "terraform" - "help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "\\bapply\\b" - "\\bgenerate\\b" @@ -112,7 +119,6 @@ tests: - name: atmos terraform apply --help enabled: true snapshot: true - diff: [] description: "Ensure atmos terraform apply --help shows help output" workdir: "./" command: "atmos" @@ -121,6 +127,11 @@ tests: - "apply" - "--help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "\\bUsage\\b" - "Flags:" @@ -131,7 +142,6 @@ tests: - name: atmos terraform apply help enabled: true snapshot: true - diff: [] description: "Ensure atmos terraform help shows help output" workdir: "./" command: "atmos" @@ -140,6 +150,11 @@ tests: - "apply" - "--help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "\\bUsage\\b" - "Flags:" @@ -150,7 +165,6 @@ tests: - name: atmos terraform non-existent enabled: true snapshot: true - diff: [] description: "Ensure atmos terraform CLI returns an error for a non-existent command." workdir: "../" command: "atmos" @@ -164,7 +178,6 @@ tests: - name: atmos terraform plan non-existent in non workspace enabled: true snapshot: true - diff: [] description: "Ensure atmos terraform CLI returns an error for a non-existent command in non existing workspace." workdir: "../" command: "atmos" @@ -180,7 +193,6 @@ tests: - name: atmos terraform plan non-existent in workspace enabled: true snapshot: true - diff: [] description: "Ensure atmos terraform CLI returns an error for a non-existent command in existing workspace." workdir: "../examples/quick-start-simple" command: "atmos" @@ -195,7 +207,6 @@ tests: - name: atmos helmfile enabled: true snapshot: true - diff: [] description: "Should show usage for helmfile" workdir: "../" command: "atmos" @@ -212,7 +223,6 @@ tests: - name: atmos helmfile non-existant enabled: true snapshot: true - diff: [] description: "Should show usage for helmfile and non-existant subcommand" workdir: "../" command: "atmos" @@ -230,7 +240,6 @@ tests: - name: atmos helmfile help enabled: true snapshot: true - diff: [] description: "Should show help for helmfile" workdir: "../" command: "atmos" @@ -238,6 +247,11 @@ tests: - "helmfile" - "help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "Available Commands:" - "apply" @@ -246,7 +260,6 @@ tests: - name: atmos helmfile --help enabled: true snapshot: true - diff: [] description: "Should show help for helmfile when using help flag" workdir: "../" command: "atmos" @@ -254,6 +267,11 @@ tests: - "helmfile" - "help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "Available Commands:" - "apply" @@ -262,7 +280,6 @@ tests: - name: atmos helmfile apply non-existant enabled: true snapshot: true - diff: [] description: "Should show error in non atmos workspace" workdir: "../" command: "atmos" @@ -278,7 +295,6 @@ tests: - name: atmos helmfile apply enabled: true snapshot: true - diff: [] description: "Should show error in atmos workspace" workdir: "../examples/demo-helmfile" command: "atmos" @@ -292,7 +308,6 @@ tests: - name: atmos helmfile apply help enabled: true snapshot: true - diff: [] description: "Should show help for atmos helmfile apply" workdir: "../" command: "atmos" @@ -301,6 +316,11 @@ tests: - "apply" - "help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "Flags:" - "--logs-file" @@ -308,7 +328,6 @@ tests: - name: atmos helmfile apply --help enabled: true snapshot: true - diff: [] description: "Should show help for atmos helmfile apply --help" workdir: "../" command: "atmos" @@ -317,6 +336,11 @@ tests: - "apply" - "--help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "Flags:" - "--logs-file" @@ -324,7 +348,6 @@ tests: - name: atmos atlantis enabled: true snapshot: true - diff: [] description: "Should show usage atmos atlantis" workdir: "../" command: "atmos" @@ -337,7 +360,6 @@ tests: - name: atmos atlantis help enabled: true snapshot: true - diff: [] description: "Should show help 'atmos atlantis help'" workdir: "../" command: "atmos" @@ -345,6 +367,11 @@ tests: - "atlantis" - "help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "Available Commands:" - "generate" @@ -352,7 +379,6 @@ tests: - name: atmos atlantis --help enabled: true snapshot: true - diff: [] description: "Should show help 'atmos atlantis --help'" workdir: "../" command: "atmos" @@ -360,6 +386,11 @@ tests: - "atlantis" - "--help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "Available Commands:" - "generate" @@ -368,7 +399,6 @@ tests: - name: atmos atlantis generate enabled: true snapshot: true - diff: [] description: "Should show usage atmos atlantis" workdir: "../" command: "atmos" @@ -382,7 +412,6 @@ tests: - name: atmos atlantis generate help enabled: true snapshot: true - diff: [] description: "Should show help 'atmos atlantis generate help'" workdir: "../" command: "atmos" @@ -391,6 +420,11 @@ tests: - "generate" - "help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "Available Commands:" - "repo-config" @@ -398,7 +432,6 @@ tests: - name: atmos atlantis generate --help enabled: true snapshot: true - diff: [] description: "Should show help 'atmos atlantis --help'" workdir: "../" command: "atmos" @@ -407,6 +440,11 @@ tests: - "generate" - "--help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "Available Commands:" - "repo-config" @@ -414,7 +452,6 @@ tests: - name: atmos atlantis generate repo-config enabled: true snapshot: true - diff: [] description: "Should show config missing in non atmos workspace 'atmos atlantis generate repo-config'" workdir: "../" command: "atmos" @@ -423,6 +460,11 @@ tests: - "generate" - "repo-config" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "atmos.yaml CLI config file specifies the directory for Atmos stacks as stacks," - "To configure and start using Atmos, refer to the following documents:" @@ -432,7 +474,6 @@ tests: - name: atmos atlantis generate repo-config help enabled: true snapshot: true - diff: [] description: "Should show help for 'atmos atlantis generate repo-config help'" workdir: "../" command: "atmos" @@ -442,6 +483,11 @@ tests: - "repo-config" - "help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "Flags:" - "--affected-only" @@ -452,7 +498,6 @@ tests: - name: atmos atlantis generate repo-config --help enabled: true snapshot: true - diff: [] description: "Should show help for 'atmos atlantis generate repo-config --help'" workdir: "../" command: "atmos" @@ -462,6 +507,11 @@ tests: - "repo-config" - "--help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" stdout: - "Flags:" - "--affected-only" @@ -472,7 +522,6 @@ tests: - name: atmos atlantis generate repo-config non-existant enabled: true snapshot: true - diff: [] description: "Should show usage for 'atmos atlantis generate repo-config non-existant'" workdir: "../" command: "atmos" @@ -489,7 +538,6 @@ tests: enabled: true description: "Should show help for 'atmos validate editorconfig help'" snapshot: true - diff: [] workdir: "../" command: atmos args: @@ -497,12 +545,16 @@ tests: - "editorconfig" - "help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" exit_code: 0 - name: atmos validate editorconfig --help enabled: true description: "Should show help for 'atmos validate editorconfig --help'" snapshot: true - diff: [] workdir: "../" command: atmos args: @@ -510,12 +562,16 @@ tests: - "editorconfig" - "--help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" exit_code: 0 - name: atmos validate editorconfig non-existant enabled: true description: "Should show usage for 'atmos validate editorconfig non-existant'" snapshot: true - diff: [] workdir: "../" command: atmos args: @@ -527,7 +583,6 @@ tests: - name: atmos about non-existent enabled: true snapshot: true - diff: [] description: "'atmos about non-existent' should show expected message" workdir: "../" command: atmos @@ -539,7 +594,6 @@ tests: - name: atmos about --help enabled: true snapshot: true - diff: [] description: "'atmos about --help' should show help" workdir: "../" command: atmos @@ -547,11 +601,15 @@ tests: - "about" - "--help" expect: + diff: + - "──────────────────────────────────────────────────────────────" + - "Update available!" + - "Atmos Releases:" + - "Install Atmos:" exit_code: 0 - name: atmos version --check --non-existent enabled: true snapshot: true - diff: [] description: "'atmos version --check --non-existent' should show invalid flag usage" workdir: "../" command: atmos @@ -564,7 +622,6 @@ tests: - name: atmos terraform plan station -s dev -- -no-color enabled: true snapshot: true - diff: [] description: "'atmos terraform plan station -s dev -- -no-color' should pass native flags to terraform without errors for flags" workdir: "../examples/quick-start-simple" command: atmos @@ -577,4 +634,4 @@ tests: - "--" - "-no-color" expect: - exit_code: 0 \ No newline at end of file + exit_code: 0 From 284db86ec7bc512c22f315e020649b0ad60e8063 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 22 Jan 2025 20:27:14 +0100 Subject: [PATCH 04/64] fix test cases --- ..._station_-s_dev_--_-no-color.stderr.golden | 0 ..._station_-s_dev_--_-no-color.stdout.golden | 58 --------------- ...rsion_--check_--non-existent.stderr.golden | 2 + ...rsion_--check_--non-existent.stdout.golden | 1 + tests/test-cases/help-and-usage.yaml | 70 +------------------ 5 files changed, 4 insertions(+), 127 deletions(-) delete mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stderr.golden delete mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stdout.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stdout.golden diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stderr.golden deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stdout.golden deleted file mode 100644 index 372c49ded..000000000 --- a/tests/snapshots/TestCLICommands_atmos_terraform_plan_station_-s_dev_--_-no-color.stdout.golden +++ /dev/null @@ -1,58 +0,0 @@ -Initializing the backend... -Initializing provider plugins... -- Reusing previous version of hashicorp/http from the dependency lock file -- Reusing previous version of hashicorp/local from the dependency lock file -- Using previously-installed hashicorp/http v3.4.5 -- Using previously-installed hashicorp/local v2.5.2 - -Terraform has been successfully initialized! -Switched to workspace "dev-station". -data.http.weather: Reading... -data.http.weather: Read complete after 0s [id=https://wttr.in/Stockholm?0&format=&lang=se&u=m] - -Terraform used the selected providers to generate the following execution -plan. Resource actions are indicated with the following symbols: - + create - -Terraform will perform the following actions: - - # local_file.cache will be created - + resource "local_file" "cache" { - + content = <<-EOT - Weather report: Stockholm - -  .-.  Light rain -  ( ).  +2(-1) °C -  (___(__)  ↗ 9 km/h -  ‘ ‘ ‘ ‘  5 km -  ‘ ‘ ‘ ‘  0.0 mm - EOT - + content_base64sha256 = (known after apply) - + content_base64sha512 = (known after apply) - + content_md5 = (known after apply) - + content_sha1 = (known after apply) - + content_sha256 = (known after apply) - + content_sha512 = (known after apply) - + directory_permission = "0777" - + file_permission = "0777" - + filename = "cache.dev.txt" - + id = (known after apply) - } - -Plan: 1 to add, 0 to change, 0 to destroy. - -Changes to Outputs: - + lang = "se" - + location = "Stockholm" - + stage = "dev" - + units = "m" - + url = "https://wttr.in/Stockholm?0&format=&lang=se&u=m" - + weather = <<-EOT - Weather report: Stockholm - -  .-.  Light rain -  ( ).  +2(-1) °C -  (___(__)  ↗ 9 km/h -  ‘ ‘ ‘ ‘  5 km -  ‘ ‘ ‘ ‘  0.0 mm - EOT diff --git a/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden new file mode 100644 index 000000000..d263306ef --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden @@ -0,0 +1,2 @@ +Error: unknown flag: --non-existent for command "atmos version" + diff --git a/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stdout.golden b/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stdout.golden new file mode 100644 index 000000000..0de83c6e1 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stdout.golden @@ -0,0 +1 @@ +Run 'atmos version --help' for usage diff --git a/tests/test-cases/help-and-usage.yaml b/tests/test-cases/help-and-usage.yaml index fed7d6dd5..4c6d74698 100644 --- a/tests/test-cases/help-and-usage.yaml +++ b/tests/test-cases/help-and-usage.yaml @@ -11,58 +11,6 @@ tests: stderr: - 'Error: Unknown command \"non-existent\" for \"atmos\"' exit_code: 1 - - name: atmos --help - enabled: true - snapshot: true - description: "Ensure atmos CLI help command lists available commands." - workdir: "./" - command: "atmos" - args: - - "--help" - expect: - diff: - - "──────────────────────────────────────────────────────────────" - - "Update available!" - - "Atmos Releases:" - - "Install Atmos:" - stdout: - - "Usage:" - - "Available Commands:" - - "\\batlantis\\b" - - "\\baws\\b" - - "\\bcompletion\\b" - - "\\bdescribe\\b" - - "\\bdocs\\b" - - "\\bhelmfile\\b" - - "\\bhelp\\b" - - "\\blist\\b" - - "\\bpro\\b" - - "\\bterraform\\b" - - "\\bvalidate\\b" - - "\\bvendor\\b" - - "\\bversion\\b" - - "\\bworkflow\\b" - - "SubCommand Aliases:" - - "\\bhf\\b" - - "Flags:" - - "\\batmos \\[subcommand\\] [<]component[>] -s [<]stack[>] -- [<]native-flags[>]" - - "for more information about a command" - stderr: - - "^$" - exit_code: 0 - - name: atmos - enabled: true - snapshot: true - description: "Ensure atmos CLI help command shows atmos config " - workdir: "./" - command: "atmos" - expect: - stdout: - - "atmos.yaml CLI config file was not found" - - "The default Atmos stacks directory is set to stacks," - stderr: - - "^$" - exit_code: 1 - name: atmos terraform enabled: true snapshot: true @@ -618,20 +566,4 @@ tests: - "--check" - "--non-existent" expect: - exit_code: 1 - - name: atmos terraform plan station -s dev -- -no-color - enabled: true - snapshot: true - description: "'atmos terraform plan station -s dev -- -no-color' should pass native flags to terraform without errors for flags" - workdir: "../examples/quick-start-simple" - command: atmos - args: - - "terraform" - - "plan" - - "station" - - "-s" - - "dev" - - "--" - - "-no-color" - expect: - exit_code: 0 + exit_code: 1 \ No newline at end of file From d21e41272d3181d9805eb91ab66c5be4cbb3e10d Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 22 Jan 2025 22:35:08 +0100 Subject: [PATCH 05/64] Add Markdown usage capability --- cmd/cmd_utils.go | 13 +++++----- cmd/markdown_help.go | 34 +++++++++++++++++++++++++ cmd/root.go | 20 +++++++++++++++ cmd/workflow.go | 7 ++++- internal/tui/templates/base_template.go | 2 +- internal/tui/templates/templater.go | 3 +-- pkg/ui/markdown/renderer.go | 2 +- 7 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 cmd/markdown_help.go diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 34a63a715..d0825b938 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -553,11 +553,17 @@ func handleHelpRequest(cmd *cobra.Command, args []string) { } } +// showUsageAndExit we display the markdown usage or fallback to our custom usage +// Markdown usage is not compatible with all outputs. We should therefore have fallback option. func showUsageAndExit(cmd *cobra.Command, args []string) { + if len(args) == 0 { + showErrorExampleFromMarkdown(cmd.CommandPath(), "") + } var suggestions []string unknownCommand := fmt.Sprintf("Error: Unknown command: %q\n\n", cmd.CommandPath()) if len(args) > 0 { + showErrorExampleFromMarkdown(cmd.CommandPath(), args[0]) suggestions = cmd.SuggestionsFor(args[0]) unknownCommand = fmt.Sprintf("Error: Unknown command %q for %q\n\n", args[0], cmd.CommandPath()) } @@ -614,10 +620,3 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin } return info } - -func getDoubleDashExample(commandPath string) string { - return fmt.Sprintf(`%s -s -- - -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.`, commandPath) -} diff --git a/cmd/markdown_help.go b/cmd/markdown_help.go new file mode 100644 index 000000000..900877f37 --- /dev/null +++ b/cmd/markdown_help.go @@ -0,0 +1,34 @@ +package cmd + +import _ "embed" + +//go:embed markdown/atmos_terraform_usage.md +var terraform string + +//go:embed markdown/atmos_terraform_plan_usage.md +var terraformPlan string + +//go:embed markdown/atmos_terraform_apply_usage.md +var terraformApply string + +type ExampleContent struct { + Content string + Suggestion string +} + +var examples map[string]ExampleContent = map[string]ExampleContent{ + "atmos_terraform": { + Content: terraform, + Suggestion: "https://atmos.tools/cli/commands/terraform/usage", + }, + "atmos_terraform_plan": { + Content: terraformPlan, + // TODO: We should update this once we have a page for terraform plan + Suggestion: "https://atmos.tools/cli/commands/terraform/usage", + }, + "atmos_terraform_apply": { + Content: terraformApply, + // TODO: We should update this once we have a page for terraform plan + Suggestion: "https://atmos.tools/cli/commands/terraform/usage", + }, +} diff --git a/cmd/root.go b/cmd/root.go index 621f02e34..7cc3c07a0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -218,3 +218,23 @@ func initCobraConfig() { // https://pkg.go.dev/github.com/c-bata/go-prompt // https://pkg.go.dev/github.com/spf13/cobra // https://scene-si.org/2017/04/20/managing-configuration-with-viper/ + +func showErrorExampleFromMarkdown(commandPath string, arg string) { + contentName := strings.ReplaceAll(commandPath, " ", "_") + if exampleContent, ok := examples[contentName]; ok { + details := fmt.Sprintf("The command `%s` is not valid\n\n%s", commandPath, exampleContent.Content) + + if len(arg) > 0 { + details = fmt.Sprintf("The command `%s` is not valid\n\n%s", commandPath+" "+arg, exampleContent.Content) + } + + if err := renderError(ErrorMessage{ + Title: "Invalid Command", + Details: details, + Suggestion: exampleContent.Suggestion, + }); err != nil { + return + } + os.Exit(1) + } +} diff --git a/cmd/workflow.go b/cmd/workflow.go index 434287417..239845d49 100644 --- a/cmd/workflow.go +++ b/cmd/workflow.go @@ -34,7 +34,12 @@ func renderError(msg ErrorMessage) error { } termWriter := termwriter.NewResponsiveWriter(os.Stdout) - screenWidth := termWriter.(*termwriter.TerminalWriter).GetWidth() + var wr *termwriter.TerminalWriter + var ok bool + if wr, ok = termWriter.(*termwriter.TerminalWriter); !ok { + return fmt.Errorf("unsupported output") + } + screenWidth := wr.GetWidth() if atmosConfig.Settings.Docs.MaxWidth > 0 { screenWidth = uint(min(atmosConfig.Settings.Docs.MaxWidth, int(screenWidth))) diff --git a/internal/tui/templates/base_template.go b/internal/tui/templates/base_template.go index 284119e90..f64e1b8fc 100644 --- a/internal/tui/templates/base_template.go +++ b/internal/tui/templates/base_template.go @@ -46,7 +46,7 @@ func getSection(section HelpTemplateSections) string { case SubCommandAliases: return `{{if (isAliasesPresent .Commands)}} -{{HeadingStyle "SubCommand Aliases:"}} +{{HeadingStyle "Subcommand Aliases:"}} {{formatCommands .Commands "subcommandAliases"}}{{end}}` case AvailableCommands: diff --git a/internal/tui/templates/templater.go b/internal/tui/templates/templater.go index f96ea3245..d0e3e66ee 100644 --- a/internal/tui/templates/templater.go +++ b/internal/tui/templates/templater.go @@ -169,14 +169,13 @@ func SetCustomUsageFunc(cmd *cobra.Command) error { UsageTemplate: GenerateFromBaseTemplate([]HelpTemplateSections{ Usage, Aliases, - Examples, AvailableCommands, NativeCommands, SubCommandAliases, Flags, GlobalFlags, AdditionalHelpTopics, - DoubleDashHelp, + Examples, Footer, }), } diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index beac0ca59..2be7512be 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -91,7 +91,7 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error if suggestion != "" { if strings.HasPrefix(suggestion, "http") { - content += fmt.Sprintf("For more information, refer to the **docs**\n%s\n", suggestion) + content += fmt.Sprintf("For more information, refer to the **docs**:\n%s\n", suggestion) } else { content += suggestion } From 06353a54d13e7f62d9ec3247777855f8dad28992 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 22 Jan 2025 22:51:19 +0100 Subject: [PATCH 06/64] usage markdowns --- cmd/markdown/atmos_terraform_apply_usage.md | 8 ++++++++ cmd/markdown/atmos_terraform_plan_usage.md | 8 ++++++++ cmd/markdown/atmos_terraform_usage.md | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 cmd/markdown/atmos_terraform_apply_usage.md create mode 100644 cmd/markdown/atmos_terraform_plan_usage.md create mode 100644 cmd/markdown/atmos_terraform_usage.md diff --git a/cmd/markdown/atmos_terraform_apply_usage.md b/cmd/markdown/atmos_terraform_apply_usage.md new file mode 100644 index 000000000..ca87a0214 --- /dev/null +++ b/cmd/markdown/atmos_terraform_apply_usage.md @@ -0,0 +1,8 @@ +Examples: + + – Execute a terraform apply + + $ atmos terraform apply -s + +For more information, refer to the **docs**: +https://atmos.tools/cli/commands/terraform/usage diff --git a/cmd/markdown/atmos_terraform_plan_usage.md b/cmd/markdown/atmos_terraform_plan_usage.md new file mode 100644 index 000000000..4cf32bd58 --- /dev/null +++ b/cmd/markdown/atmos_terraform_plan_usage.md @@ -0,0 +1,8 @@ +Examples: + + – Execute a terraform plan + + $ atmos terraform plan -s + +For more information, refer to the **docs**: +https://atmos.tools/cli/commands/terraform/usage diff --git a/cmd/markdown/atmos_terraform_usage.md b/cmd/markdown/atmos_terraform_usage.md new file mode 100644 index 000000000..67c7828ff --- /dev/null +++ b/cmd/markdown/atmos_terraform_usage.md @@ -0,0 +1,8 @@ +Examples: + + – Execute a terraform + + $ atmos terraform [sub-command] -s + +For more information, refer to the **docs**: +https://atmos.tools/cli/commands/terraform/usage From bb9705b49386a2771772cf76eb30d8c7cb0d0cc5 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Thu, 23 Jan 2025 21:45:37 +0100 Subject: [PATCH 07/64] example hint updated --- cmd/atlantis.go | 1 + cmd/aws.go | 1 + cmd/helmfile.go | 1 + cmd/markdown/atmos_terraform_apply_usage.md | 5 ++--- cmd/markdown/atmos_terraform_plan_usage.md | 5 ++--- cmd/markdown/atmos_terraform_usage.md | 5 ++--- cmd/markdown_help.go | 2 ++ cmd/terraform.go | 2 ++ pkg/ui/markdown/renderer.go | 2 +- tests/test-cases/help-and-usage.yaml | 2 +- 10 files changed, 15 insertions(+), 11 deletions(-) diff --git a/cmd/atlantis.go b/cmd/atlantis.go index 560dc7da9..8c3f6e329 100644 --- a/cmd/atlantis.go +++ b/cmd/atlantis.go @@ -14,5 +14,6 @@ var atlantisCmd = &cobra.Command{ } func init() { + atlantisCmd.PersistentFlags().Bool("", false, doubleDashHint) RootCmd.AddCommand(atlantisCmd) } diff --git a/cmd/aws.go b/cmd/aws.go index a65b13fdd..38524824b 100644 --- a/cmd/aws.go +++ b/cmd/aws.go @@ -14,5 +14,6 @@ var awsCmd = &cobra.Command{ } func init() { + awsCmd.PersistentFlags().Bool("", false, doubleDashHint) RootCmd.AddCommand(awsCmd) } diff --git a/cmd/helmfile.go b/cmd/helmfile.go index 0c62ba872..dde42a071 100644 --- a/cmd/helmfile.go +++ b/cmd/helmfile.go @@ -20,6 +20,7 @@ func init() { // https://github.com/spf13/cobra/issues/739 helmfileCmd.DisableFlagParsing = true helmfileCmd.PersistentFlags().StringP("stack", "s", "", "atmos helmfile -s ") + helmfileCmd.PersistentFlags().Bool("", false, doubleDashHint) RootCmd.AddCommand(helmfileCmd) } diff --git a/cmd/markdown/atmos_terraform_apply_usage.md b/cmd/markdown/atmos_terraform_apply_usage.md index ca87a0214..efab0725d 100644 --- a/cmd/markdown/atmos_terraform_apply_usage.md +++ b/cmd/markdown/atmos_terraform_apply_usage.md @@ -2,7 +2,6 @@ Examples: – Execute a terraform apply +``` $ atmos terraform apply -s - -For more information, refer to the **docs**: -https://atmos.tools/cli/commands/terraform/usage +``` \ No newline at end of file diff --git a/cmd/markdown/atmos_terraform_plan_usage.md b/cmd/markdown/atmos_terraform_plan_usage.md index 4cf32bd58..12929a77f 100644 --- a/cmd/markdown/atmos_terraform_plan_usage.md +++ b/cmd/markdown/atmos_terraform_plan_usage.md @@ -2,7 +2,6 @@ Examples: – Execute a terraform plan +``` $ atmos terraform plan -s - -For more information, refer to the **docs**: -https://atmos.tools/cli/commands/terraform/usage +``` \ No newline at end of file diff --git a/cmd/markdown/atmos_terraform_usage.md b/cmd/markdown/atmos_terraform_usage.md index 67c7828ff..502c7abb5 100644 --- a/cmd/markdown/atmos_terraform_usage.md +++ b/cmd/markdown/atmos_terraform_usage.md @@ -2,7 +2,6 @@ Examples: – Execute a terraform +``` $ atmos terraform [sub-command] -s - -For more information, refer to the **docs**: -https://atmos.tools/cli/commands/terraform/usage +``` \ No newline at end of file diff --git a/cmd/markdown_help.go b/cmd/markdown_help.go index 900877f37..724a45681 100644 --- a/cmd/markdown_help.go +++ b/cmd/markdown_help.go @@ -16,6 +16,8 @@ type ExampleContent struct { Suggestion string } +var doubleDashHint string = "Double dashes 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." + var examples map[string]ExampleContent = map[string]ExampleContent{ "atmos_terraform": { Content: terraform, diff --git a/cmd/terraform.go b/cmd/terraform.go index 452956b8c..0c45d7ea1 100644 --- a/cmd/terraform.go +++ b/cmd/terraform.go @@ -18,6 +18,7 @@ var terraformCmd = &cobra.Command{ Short: "Execute Terraform commands (e.g., plan, apply, destroy) using Atmos stack configurations", Long: `This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management.`, FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: true}, + Example: `atmos terraform [sub-command] -s `, PostRunE: func(cmd *cobra.Command, args []string) error { info := getConfigAndStacksInfo("terraform", cmd, args) return hooks.RunE(cmd, args, &info) @@ -50,6 +51,7 @@ func init() { // https://github.com/spf13/cobra/issues/739 terraformCmd.DisableFlagParsing = true terraformCmd.PersistentFlags().StringP("stack", "s", "", "atmos terraform -s ") + terraformCmd.PersistentFlags().Bool("", false, doubleDashHint) attachTerraformCommands(terraformCmd) RootCmd.AddCommand(terraformCmd) } diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index 2be7512be..5f2e394e6 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -91,7 +91,7 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error if suggestion != "" { if strings.HasPrefix(suggestion, "http") { - content += fmt.Sprintf("For more information, refer to the **docs**:\n%s\n", suggestion) + content += fmt.Sprintf("\nFor more information, refer to the [docs](%s)\n", suggestion) } else { content += suggestion } diff --git a/tests/test-cases/help-and-usage.yaml b/tests/test-cases/help-and-usage.yaml index 4c6d74698..2e387e9a2 100644 --- a/tests/test-cases/help-and-usage.yaml +++ b/tests/test-cases/help-and-usage.yaml @@ -566,4 +566,4 @@ tests: - "--check" - "--non-existent" expect: - exit_code: 1 \ No newline at end of file + exit_code: 1 From 6317c43030661890082a2421c7913c84c076c777 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Fri, 24 Jan 2025 00:28:00 +0100 Subject: [PATCH 08/64] fix tests --- cmd/workflow.go | 10 +++++++--- .../TestCLICommands_atmos_--help.stdout.golden | 8 +------- ...ICommands_atmos_terraform_help.stdout.golden | 17 +++++++++++++---- ...heck_atmos_--help_in_empty-dir.stdout.golden | 8 +------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/cmd/workflow.go b/cmd/workflow.go index 239845d49..4d4cc7085 100644 --- a/cmd/workflow.go +++ b/cmd/workflow.go @@ -111,10 +111,14 @@ var workflowCmd = &cobra.Command{ // Create a terminal writer to get the optimal width termWriter := termwriter.NewResponsiveWriter(os.Stdout) - screenWidth := termWriter.(*termwriter.TerminalWriter).GetWidth() - + var wr *termwriter.TerminalWriter + var ok bool + if wr, ok = termWriter.(*termwriter.TerminalWriter); !ok { + u.LogErrorAndExit(schema.AtmosConfiguration{}, fmt.Errorf("unsupported output")) + } + screenWidth := wr.GetWidth() if atmosConfig.Settings.Docs.MaxWidth > 0 { - screenWidth = uint(min(atmosConfig.Settings.Docs.MaxWidth, int(screenWidth))) + screenWidth = uint(min(atmosConfig.Settings.Docs.MaxWidth, int(wr.GetWidth()))) } renderer, err := markdown.NewRenderer( diff --git a/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden index af98afaad..398fe56f1 100644 --- a/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden @@ -25,7 +25,7 @@ Available Commands: version Display the version of Atmos you are running and check for updates workflow Run predefined tasks using workflows -SubCommand Aliases: +Subcommand Aliases: hf Alias of "atmos helmfile" command tf Alias of "atmos terraform" command @@ -52,11 +52,5 @@ Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -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. - -Example: - atmos [subcommand] -s -- - Use "atmos [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index c77745dbc..65db538ee 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -49,6 +49,12 @@ Native terraform Commands: Flags: + -- Double dashes 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. (default "false") + --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. @@ -84,11 +90,14 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -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. -Example: - atmos terraform [subcommand] -s -- +Examples: + +– Execute a terraform + +``` + $ atmos terraform [sub-command] -s +``` Use "atmos terraform [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden b/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden index af98afaad..398fe56f1 100644 --- a/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden +++ b/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden @@ -25,7 +25,7 @@ Available Commands: version Display the version of Atmos you are running and check for updates workflow Run predefined tasks using workflows -SubCommand Aliases: +Subcommand Aliases: hf Alias of "atmos helmfile" command tf Alias of "atmos terraform" command @@ -52,11 +52,5 @@ Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -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. - -Example: - atmos [subcommand] -s -- - Use "atmos [subcommand] --help" for more information about a command. From 8b74647f0c556f7be42b3ca936b4d4835a43696e Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 26 Jan 2025 12:31:46 +0100 Subject: [PATCH 09/64] Update usage display to markdown glamour --- cmd/cmd_utils.go | 88 ++++++++++++------- cmd/markdown_help.go | 13 +++ cmd/root.go | 20 ----- cmd/terraform.go | 2 +- cmd/terraform_commands.go | 4 +- cmd/workflow.go | 108 ++---------------------- internal/tui/templates/base_template.go | 12 +-- internal/tui/templates/templater.go | 20 +++++ internal/tui/utils/utils.go | 3 +- pkg/ui/markdown/parser.go | 30 ------- pkg/ui/markdown/renderer.go | 63 +++++++++----- pkg/ui/markdown/styles.go | 8 +- 12 files changed, 149 insertions(+), 222 deletions(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index d0825b938..c8899f9ae 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -557,45 +557,25 @@ func handleHelpRequest(cmd *cobra.Command, args []string) { // Markdown usage is not compatible with all outputs. We should therefore have fallback option. func showUsageAndExit(cmd *cobra.Command, args []string) { if len(args) == 0 { - showErrorExampleFromMarkdown(cmd.CommandPath(), "") + showErrorExampleFromMarkdown(cmd, "") } - var suggestions []string - unknownCommand := fmt.Sprintf("Error: Unknown command: %q\n\n", cmd.CommandPath()) - if len(args) > 0 { - showErrorExampleFromMarkdown(cmd.CommandPath(), args[0]) - suggestions = cmd.SuggestionsFor(args[0]) - unknownCommand = fmt.Sprintf("Error: Unknown command %q for %q\n\n", args[0], cmd.CommandPath()) + showErrorExampleFromMarkdown(cmd, args[0]) } - u.PrintErrorInColor(unknownCommand) - if len(suggestions) > 0 { - u.PrintMessage("Did you mean this?") - for _, suggestion := range suggestions { - u.PrintMessage(fmt.Sprintf(" %s\n", suggestion)) - } - } else { - // Retrieve valid subcommands dynamically - validSubcommands := []string{} - for _, subCmd := range cmd.Commands() { - validSubcommands = append(validSubcommands, subCmd.Name()) - } - if len(validSubcommands) > 0 { - u.PrintMessage("Valid subcommands are:") - for _, sub := range validSubcommands { - u.PrintMessage(fmt.Sprintf(" %s", sub)) - } - } else { - u.PrintMessage("No valid subcommands found") - } - } - u.PrintMessage(fmt.Sprintf("\nRun '%s --help' for usage", cmd.CommandPath())) os.Exit(1) } func showFlagUsageAndExit(cmd *cobra.Command, err error) error { - unknownCommand := fmt.Sprintf("Error: %v for command %q\n\n", err.Error(), cmd.CommandPath()) - u.PrintErrorInColor(unknownCommand) - u.PrintMessage(fmt.Sprintf("Run '%s --help' for usage", cmd.CommandPath())) + unknownCommand := fmt.Sprintf("%v for command `%s`\n\n", err.Error(), cmd.CommandPath()) + args := strings.Split(err.Error(), ": ") + if len(args) == 2 { + unknownCommand = fmt.Sprintf("%s `%s` for command `%s`\n\n", args[0], args[1], cmd.CommandPath()) + } + renderError(ErrorMessage{ + Title: "Invalid Flag", + Details: unknownCommand, + Suggestion: fmt.Sprintf("Run `%s --help` for usage", cmd.CommandPath()), + }) os.Exit(1) return nil } @@ -620,3 +600,47 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin } return info } + +func showErrorExampleFromMarkdown(cmd *cobra.Command, arg string) { + commandPath := cmd.CommandPath() + contentName := strings.ReplaceAll(commandPath, " ", "_") + suggestions := []string{} + details := fmt.Sprintf("The command `%s` is not valid\n\n", commandPath) + if len(arg) > 0 { + details = fmt.Sprintf("Unknown command `%s` for `%s`\n\n", arg, commandPath) + } else if len(cmd.Commands()) != 0 && arg == "" { + details = fmt.Sprintf("The command `%s` requires a subcommand\n\n", commandPath) + } + if len(arg) > 0 { + suggestions = cmd.SuggestionsFor(arg) + } + if len(suggestions) > 0 { + details = details + "Did you mean this?\n" + for _, suggestion := range suggestions { + details += "* " + suggestion + "\n" + } + } else { + if len(cmd.Commands()) > 0 { + details += "Valid subcommands are:\n" + } + // Retrieve valid subcommands dynamically + for _, subCmd := range cmd.Commands() { + details = details + "* " + subCmd.Name() + "\n" + } + if len(cmd.Commands()) == 0 && arg != "" { + details += "No valid subcommands found for `" + cmd.CommandPath() + "`\n" + } + } + suggestion := fmt.Sprintf("\nRun '%s --help' for usage", cmd.CommandPath()) + if exampleContent, ok := examples[contentName]; ok { + suggestion = exampleContent.Suggestion + details += "\n## Usage Examples:\n" + exampleContent.Content + } + if err := renderError(ErrorMessage{ + Title: "Incorrect Usage", + Details: details, + Suggestion: suggestion, + }); err != nil { + return + } +} diff --git a/cmd/markdown_help.go b/cmd/markdown_help.go index 724a45681..c0917810c 100644 --- a/cmd/markdown_help.go +++ b/cmd/markdown_help.go @@ -11,6 +11,12 @@ var terraformPlan string //go:embed markdown/atmos_terraform_apply_usage.md var terraformApply string +//go:embed markdown/atmos_workflow_usage.md +var workflow string + +//go:embed markdown/atmos_about_usage.md +var atmosAbout string + type ExampleContent struct { Content string Suggestion string @@ -33,4 +39,11 @@ var examples map[string]ExampleContent = map[string]ExampleContent{ // TODO: We should update this once we have a page for terraform plan Suggestion: "https://atmos.tools/cli/commands/terraform/usage", }, + "atmos_workflow": { + Content: workflow, + Suggestion: "https://atmos.tools/cli/commands/workflow/", + }, + "atmos_about": { + Content: atmosAbout, + }, } diff --git a/cmd/root.go b/cmd/root.go index 7cc3c07a0..621f02e34 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -218,23 +218,3 @@ func initCobraConfig() { // https://pkg.go.dev/github.com/c-bata/go-prompt // https://pkg.go.dev/github.com/spf13/cobra // https://scene-si.org/2017/04/20/managing-configuration-with-viper/ - -func showErrorExampleFromMarkdown(commandPath string, arg string) { - contentName := strings.ReplaceAll(commandPath, " ", "_") - if exampleContent, ok := examples[contentName]; ok { - details := fmt.Sprintf("The command `%s` is not valid\n\n%s", commandPath, exampleContent.Content) - - if len(arg) > 0 { - details = fmt.Sprintf("The command `%s` is not valid\n\n%s", commandPath+" "+arg, exampleContent.Content) - } - - if err := renderError(ErrorMessage{ - Title: "Invalid Command", - Details: details, - Suggestion: exampleContent.Suggestion, - }); err != nil { - return - } - os.Exit(1) - } -} diff --git a/cmd/terraform.go b/cmd/terraform.go index 0c45d7ea1..1dc5c9d86 100644 --- a/cmd/terraform.go +++ b/cmd/terraform.go @@ -18,7 +18,7 @@ var terraformCmd = &cobra.Command{ Short: "Execute Terraform commands (e.g., plan, apply, destroy) using Atmos stack configurations", Long: `This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management.`, FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: true}, - Example: `atmos terraform [sub-command] -s `, + Example: terraform, PostRunE: func(cmd *cobra.Command, args []string) error { info := getConfigAndStacksInfo("terraform", cmd, args) return hooks.RunE(cmd, args, &info) diff --git a/cmd/terraform_commands.go b/cmd/terraform_commands.go index 1bb077145..d0515e077 100644 --- a/cmd/terraform_commands.go +++ b/cmd/terraform_commands.go @@ -14,7 +14,7 @@ func getTerraformCommands() []*cobra.Command { Use: "plan", Short: "Show changes required by the current configuration", Long: "Generate an execution plan, which shows what actions Terraform will take to reach the desired state of the configuration.", - Example: "atmos terraform plan -s ", + Example: terraformPlan, Annotations: map[string]string{ "nativeCommand": "true", }, @@ -23,7 +23,7 @@ func getTerraformCommands() []*cobra.Command { Use: "apply", Short: "Apply changes to infrastructure", Long: "Apply the changes required to reach the desired state of the configuration. This will prompt for confirmation before making changes.", - Example: "atmos terraform apply -s ", + Example: terraformApply, Annotations: map[string]string{ "nativeCommand": "true", }, diff --git a/cmd/workflow.go b/cmd/workflow.go index 4d4cc7085..c36fa17f5 100644 --- a/cmd/workflow.go +++ b/cmd/workflow.go @@ -9,8 +9,6 @@ import ( "github.com/spf13/cobra" e "github.com/cloudposse/atmos/internal/exec" - termwriter "github.com/cloudposse/atmos/internal/tui/templates/term" - cfg "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/schema" "github.com/cloudposse/atmos/pkg/ui/markdown" u "github.com/cloudposse/atmos/pkg/utils" @@ -28,52 +26,19 @@ type ErrorMessage struct { // renderError renders an error message using the markdown renderer func renderError(msg ErrorMessage) error { - atmosConfig, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false) + renderer, err := markdown.NewTerminalMarkdownRenderer(atmosConfig) if err != nil { - return fmt.Errorf("failed to initialize atmos config: %w", err) + return err } - - termWriter := termwriter.NewResponsiveWriter(os.Stdout) - var wr *termwriter.TerminalWriter - var ok bool - if wr, ok = termWriter.(*termwriter.TerminalWriter); !ok { - return fmt.Errorf("unsupported output") - } - screenWidth := wr.GetWidth() - - if atmosConfig.Settings.Docs.MaxWidth > 0 { - screenWidth = uint(min(atmosConfig.Settings.Docs.MaxWidth, int(screenWidth))) - } - - renderer, err := markdown.NewRenderer( - markdown.WithWidth(screenWidth), - ) - if err != nil { - return fmt.Errorf("failed to create markdown renderer: %w", err) - } - rendered, err := renderer.RenderError(msg.Title, msg.Details, msg.Suggestion) if err != nil { return fmt.Errorf("failed to render error message: %w", err) } - fmt.Print(rendered) + fmt.Print(rendered + "\n") return nil } -// getMarkdownSection returns a section from the markdown file -func getMarkdownSection(title string) (details, suggestion string) { - sections := markdown.ParseMarkdownSections(workflowMarkdown) - if section, ok := sections[title]; ok { - parts := markdown.SplitMarkdownContent(section) - if len(parts) >= 2 { - return parts[0], parts[1] - } - return section, "" - } - return "", "" -} - // workflowCmd executes a workflow var workflowCmd = &cobra.Command{ Use: "workflow", @@ -103,60 +68,7 @@ var workflowCmd = &cobra.Command{ // If no file is provided, show invalid command error with usage information if workflowFile == "" { - // Get atmos configuration - atmosConfig, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false) - if err != nil { - u.LogErrorAndExit(schema.AtmosConfiguration{}, fmt.Errorf("failed to initialize atmos config: %w", err)) - } - - // Create a terminal writer to get the optimal width - termWriter := termwriter.NewResponsiveWriter(os.Stdout) - var wr *termwriter.TerminalWriter - var ok bool - if wr, ok = termWriter.(*termwriter.TerminalWriter); !ok { - u.LogErrorAndExit(schema.AtmosConfiguration{}, fmt.Errorf("unsupported output")) - } - screenWidth := wr.GetWidth() - if atmosConfig.Settings.Docs.MaxWidth > 0 { - screenWidth = uint(min(atmosConfig.Settings.Docs.MaxWidth, int(wr.GetWidth()))) - } - - renderer, err := markdown.NewRenderer( - markdown.WithWidth(screenWidth), - ) - if err != nil { - u.LogErrorAndExit(schema.AtmosConfiguration{}, fmt.Errorf("failed to create markdown renderer: %w", err)) - } - - // Generate the error message dynamically using H1 styling - errorMsg := fmt.Sprintf("# Invalid Command\n\nThe command `atmos workflow %s` is not valid.\n\n", args[0]) - content := errorMsg + workflowMarkdown - rendered, err := renderer.Render(content) - if err != nil { - u.LogErrorAndExit(schema.AtmosConfiguration{}, fmt.Errorf("failed to render markdown: %w", err)) - } - - // Remove duplicate URLs and format output - lines := strings.Split(rendered, "\n") - var result []string - seenURL := false - - for _, line := range lines { - trimmed := strings.TrimSpace(line) - if strings.Contains(trimmed, "https://") { - if !seenURL { - seenURL = true - result = append(result, line) - } - } else if strings.HasPrefix(trimmed, "$") { - result = append(result, " "+strings.TrimSpace(line)) - } else if trimmed != "" { - result = append(result, line) - } - } - - fmt.Print("\n" + strings.Join(result, "\n") + "\n\n") - os.Exit(1) + cmd.Usage() } // Execute the workflow command @@ -164,21 +76,19 @@ var workflowCmd = &cobra.Command{ if err != nil { // Format common error messages if strings.Contains(err.Error(), "does not exist") { - details, suggestion := getMarkdownSection("Workflow File Not Found") err := renderError(ErrorMessage{ Title: "Workflow File Not Found", - Details: details, - Suggestion: suggestion, + Details: fmt.Sprintf("`%v` was not found", workflowFile), + Suggestion: "", }) if err != nil { u.LogErrorAndExit(schema.AtmosConfiguration{}, err) } } else if strings.Contains(err.Error(), "does not have the") { - details, suggestion := getMarkdownSection("Invalid Workflow") err := renderError(ErrorMessage{ Title: "Invalid Workflow", - Details: details, - Suggestion: suggestion, + Details: err.Error(), + Suggestion: "", }) if err != nil { u.LogErrorAndExit(schema.AtmosConfiguration{}, err) @@ -187,7 +97,7 @@ var workflowCmd = &cobra.Command{ // For other errors, use the standard error handler u.LogErrorAndExit(schema.AtmosConfiguration{}, err) } - return + os.Exit(1) } }, } diff --git a/internal/tui/templates/base_template.go b/internal/tui/templates/base_template.go index f64e1b8fc..af29a2681 100644 --- a/internal/tui/templates/base_template.go +++ b/internal/tui/templates/base_template.go @@ -13,7 +13,6 @@ const ( GlobalFlags AdditionalHelpTopics NativeCommands - DoubleDashHelp Footer ) @@ -62,7 +61,7 @@ func getSection(section HelpTemplateSections) string { {{HeadingStyle "Examples:"}} -{{.Example}}{{end}}` +{{formatExamples .Example}}{{end}}` case Flags: return `{{if .HasAvailableLocalFlags}} @@ -89,17 +88,8 @@ func getSection(section HelpTemplateSections) string { {{if .Runnable}} {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} {{.CommandPath}} [sub-command] [flags]{{end}}` - case DoubleDashHelp: - return ` - -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. - -Example: - {{.CommandPath}} {{if gt (len .Commands) 0}}[subcommand]{{end}} -s -- ` case Footer: return `{{if .HasAvailableSubCommands}} - Use "{{.CommandPath}} {{if gt (len .Commands) 0}}[subcommand]{{end}} --help" for more information about a command.{{end}}` default: return "" diff --git a/internal/tui/templates/templater.go b/internal/tui/templates/templater.go index d0e3e66ee..3e0bc5113 100644 --- a/internal/tui/templates/templater.go +++ b/internal/tui/templates/templater.go @@ -7,6 +7,8 @@ import ( "strings" "github.com/charmbracelet/lipgloss" + "github.com/cloudposse/atmos/pkg/schema" + "github.com/cloudposse/atmos/pkg/ui/markdown" "github.com/cloudposse/atmos/pkg/ui/theme" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -84,6 +86,23 @@ func isAliasesPresent(cmds []*cobra.Command) bool { return len(filterCommands(cmds, true)) > 0 } +func formatExamples(example string) string { + render, err := markdown.NewTerminalMarkdownRenderer(schema.AtmosConfiguration{}) + if err != nil { + return "" + } + data, err := render.RenderError("", example, "") + if err == nil { + return data + } + + data, err = render.RenderAscii(example) + if err == nil { + return data + } + return "" +} + // formatCommands formats a slice of cobra commands with proper styling func formatCommands(cmds []*cobra.Command, listType string) string { var maxLen int @@ -184,6 +203,7 @@ func SetCustomUsageFunc(cmd *cobra.Command) error { cobra.AddTemplateFunc("isAliasesPresent", isAliasesPresent) cobra.AddTemplateFunc("isNativeCommandsAvailable", isNativeCommandsAvailable) cobra.AddTemplateFunc("formatCommands", formatCommands) + cobra.AddTemplateFunc("formatExamples", formatExamples) return nil } diff --git a/internal/tui/utils/utils.go b/internal/tui/utils/utils.go index e737ba3cf..57aa4b33a 100644 --- a/internal/tui/utils/utils.go +++ b/internal/tui/utils/utils.go @@ -8,6 +8,7 @@ import ( "github.com/alecthomas/chroma/quick" "github.com/arsham/figurine/figurine" "github.com/charmbracelet/glamour" + "github.com/cloudposse/atmos/pkg/schema" mdstyle "github.com/cloudposse/atmos/pkg/ui/markdown" "github.com/jwalton/go-supportscolor" xterm "golang.org/x/term" @@ -39,7 +40,7 @@ func RenderMarkdown(markdownText string, style string) (string, error) { } // Get the custom style from atmos config - customStyle, err := mdstyle.GetDefaultStyle() + customStyle, err := mdstyle.GetDefaultStyle(schema.AtmosConfiguration{}) if err != nil { return "", fmt.Errorf("failed to get markdown style: %w", err) } diff --git a/pkg/ui/markdown/parser.go b/pkg/ui/markdown/parser.go index 9e9176cce..dad424b25 100644 --- a/pkg/ui/markdown/parser.go +++ b/pkg/ui/markdown/parser.go @@ -4,36 +4,6 @@ import ( "strings" ) -// ParseMarkdownSections parses a markdown string and returns a map of section titles to their content -func ParseMarkdownSections(content string) map[string]string { - sections := make(map[string]string) - lines := strings.Split(content, "\n") - - var currentTitle string - var currentContent []string - - for _, line := range lines { - if strings.HasPrefix(line, "# ") { - // If we have a previous section, save it - if currentTitle != "" { - sections[currentTitle] = strings.TrimSpace(strings.Join(currentContent, "\n")) - } - // Start new section - currentTitle = strings.TrimPrefix(line, "# ") - currentContent = []string{} - } else if currentTitle != "" { - currentContent = append(currentContent, line) - } - } - - // Save the last section - if currentTitle != "" { - sections[currentTitle] = strings.TrimSpace(strings.Join(currentContent, "\n")) - } - - return sections -} - // SplitMarkdownContent splits markdown content into details and suggestion parts func SplitMarkdownContent(content string) []string { parts := strings.Split(content, "\n\n") diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index 5f2e394e6..f48162b1f 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -2,21 +2,26 @@ package markdown import ( "fmt" + "os" "strings" "github.com/charmbracelet/glamour" + "github.com/charmbracelet/glamour/styles" + "github.com/cloudposse/atmos/internal/tui/templates/term" + "github.com/cloudposse/atmos/pkg/schema" "github.com/muesli/termenv" ) // Renderer is a markdown renderer using Glamour type Renderer struct { - renderer *glamour.TermRenderer - width uint - profile termenv.Profile + renderer *glamour.TermRenderer + width uint + profile termenv.Profile + atmosConfig *schema.AtmosConfiguration } // NewRenderer creates a new markdown renderer with the given options -func NewRenderer(opts ...Option) (*Renderer, error) { +func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Renderer, error) { r := &Renderer{ width: 80, // default width profile: termenv.ColorProfile(), // default color profile @@ -28,7 +33,7 @@ func NewRenderer(opts ...Option) (*Renderer, error) { } // Get default style - style, err := GetDefaultStyle() + style, err := GetDefaultStyle(atmosConfig) if err != nil { return nil, err } @@ -54,6 +59,19 @@ func (r *Renderer) Render(content string) (string, error) { return r.renderer.Render(content) } +func (r *Renderer) RenderAscii(content string) (string, error) { + renderer, err := glamour.NewTermRenderer( + glamour.WithStandardStyle(styles.AsciiStyle), + glamour.WithWordWrap(int(r.width)), + glamour.WithColorProfile(r.profile), + glamour.WithEmoji(), + ) + if err != nil { + return "", err + } + return renderer.Render(content) +} + // RenderWithStyle renders markdown content with a specific style func (r *Renderer) RenderWithStyle(content string, style []byte) (string, error) { renderer, err := glamour.NewTermRenderer( @@ -86,12 +104,12 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error } if details != "" { - content += fmt.Sprintf("%s\n\n", details) + content += fmt.Sprintf("%s", details) } if suggestion != "" { if strings.HasPrefix(suggestion, "http") { - content += fmt.Sprintf("\nFor more information, refer to the [docs](%s)\n", suggestion) + content += fmt.Sprintf("\nFor more information, refer to the [docs](%s)", suggestion) } else { content += suggestion } @@ -105,19 +123,13 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error // Remove duplicate URLs and trailing newlines lines := strings.Split(rendered, "\n") var result []string - seenURL := false // Create a purple style purpleStyle := termenv.Style{}.Foreground(r.profile.Color(Purple)).Bold() for _, line := range lines { trimmed := strings.TrimSpace(line) - if strings.Contains(trimmed, "https://") { - if !seenURL { - seenURL = true - result = append(result, line) - } - } else if strings.HasPrefix(trimmed, "$") { + if strings.HasPrefix(trimmed, "$") { // Add custom styling for command examples styled := purpleStyle.Styled(strings.TrimSpace(line)) result = append(result, " "+styled) @@ -127,7 +139,7 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error } // Add a single newline at the end plus extra spacing - return "\n" + strings.Join(result, "\n") + "\n\n", nil + return strings.Join(result, "\n"), nil } // RenderSuccess renders a success message with specific styling @@ -151,9 +163,22 @@ func WithWidth(width uint) Option { } } -// WithColorProfile sets the color profile for the renderer -func WithColorProfile(profile termenv.Profile) Option { - return func(r *Renderer) { - r.profile = profile +func NewTerminalMarkdownRenderer(atmosConfig schema.AtmosConfiguration) (*Renderer, error) { + maxWidth := atmosConfig.Settings.Docs.MaxWidth + // Create a terminal writer to get the optimal width + termWriter := term.NewResponsiveWriter(os.Stdout) + var wr *term.TerminalWriter + var ok bool + var screenWidth uint = 1000 + if wr, ok = termWriter.(*term.TerminalWriter); ok { + screenWidth = wr.GetWidth() } + if maxWidth > 0 { + screenWidth = uint(min(maxWidth, int(wr.GetWidth()))) + } + + return NewRenderer( + atmosConfig, + WithWidth(screenWidth), + ) } diff --git a/pkg/ui/markdown/styles.go b/pkg/ui/markdown/styles.go index 549ef3706..44e54cb65 100644 --- a/pkg/ui/markdown/styles.go +++ b/pkg/ui/markdown/styles.go @@ -4,7 +4,6 @@ import ( "encoding/json" "github.com/charmbracelet/glamour/ansi" - "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/schema" ) @@ -22,12 +21,7 @@ func applyStyleSafely(style *ansi.StylePrimitive, color string) { // GetDefaultStyle returns the markdown style configuration from atmos.yaml settings // or falls back to built-in defaults if not configured -func GetDefaultStyle() ([]byte, error) { - atmosConfig, err := config.InitCliConfig(schema.ConfigAndStacksInfo{}, false) - if err != nil { - return getBuiltinDefaultStyle() - } - +func GetDefaultStyle(atmosConfig schema.AtmosConfiguration) ([]byte, error) { // Get the built-in default style defaultBytes, err := getBuiltinDefaultStyle() if err != nil { From f0fcf3c68411909414e1404f06d53915f7f015a4 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 26 Jan 2025 13:00:34 +0100 Subject: [PATCH 10/64] CheckTTYSupport should be in term package --- internal/exec/terraform_outputs.go | 3 ++- internal/exec/vendor_component_utils.go | 11 ++--------- internal/exec/vendor_model.go | 5 +++-- internal/exec/vendor_model_component.go | 3 ++- internal/exec/vendor_utils.go | 3 ++- internal/tui/templates/term/term_writer.go | 10 ++++++++-- pkg/list/list_workflows.go | 4 ++-- 7 files changed, 21 insertions(+), 18 deletions(-) diff --git a/internal/exec/terraform_outputs.go b/internal/exec/terraform_outputs.go index 2010d58f8..c2433228c 100644 --- a/internal/exec/terraform_outputs.go +++ b/internal/exec/terraform_outputs.go @@ -13,6 +13,7 @@ import ( "github.com/charmbracelet/bubbles/spinner" tea "github.com/charmbracelet/bubbletea" + "github.com/cloudposse/atmos/internal/tui/templates/term" cfg "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/schema" "github.com/cloudposse/atmos/pkg/ui/theme" @@ -234,7 +235,7 @@ func GetTerraformOutput( s.Style = theme.Styles.Link var opts []tea.ProgramOption - if !CheckTTYSupport() { + if !term.CheckTTYSupport() { // set tea.WithInput(nil) workaround tea program not run on not TTY mod issue opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)} u.LogTrace(*atmosConfig, "No TTY detected. Falling back to basic output. This can happen when no terminal is attached or when commands are pipelined.") diff --git a/internal/exec/vendor_component_utils.go b/internal/exec/vendor_component_utils.go index 94088bdf1..52dd53b82 100644 --- a/internal/exec/vendor_component_utils.go +++ b/internal/exec/vendor_component_utils.go @@ -15,8 +15,8 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/hairyhenderson/gomplate/v3" cp "github.com/otiai10/copy" - "golang.org/x/term" + "github.com/cloudposse/atmos/internal/tui/templates/term" cfg "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/schema" u "github.com/cloudposse/atmos/pkg/utils" @@ -363,7 +363,7 @@ func ExecuteComponentVendorInternal( } var opts []tea.ProgramOption // Disable TUI if no TTY support is available - if !CheckTTYSupport() { + if !term.CheckTTYSupport() { opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)} u.LogWarning(atmosConfig, "TTY is not supported. Running in non-interactive mode") } @@ -373,10 +373,3 @@ func ExecuteComponentVendorInternal( } return nil } - -// CheckTTYSupport checks if stdout supports TTY for displaying the progress UI. -func CheckTTYSupport() bool { - fd := int(os.Stdout.Fd()) - isTerminal := term.IsTerminal(fd) - return isTerminal -} diff --git a/internal/exec/vendor_model.go b/internal/exec/vendor_model.go index 6ddf14e71..8b1cedc0d 100644 --- a/internal/exec/vendor_model.go +++ b/internal/exec/vendor_model.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/go-getter" cp "github.com/otiai10/copy" + "github.com/cloudposse/atmos/internal/tui/templates/term" "github.com/cloudposse/atmos/pkg/schema" "github.com/cloudposse/atmos/pkg/ui/theme" u "github.com/cloudposse/atmos/pkg/utils" @@ -86,7 +87,7 @@ func newModelAtmosVendorInternal(pkgs []pkgAtmosVendor, dryRun bool, atmosConfig if len(pkgs) == 0 { return modelVendor{done: true}, nil } - tty := CheckTTYSupport() + isTTY := term.CheckTTYSupport() var vendorPks []pkgVendor for _, pkg := range pkgs { p := pkgVendor{ @@ -102,7 +103,7 @@ func newModelAtmosVendorInternal(pkgs []pkgAtmosVendor, dryRun bool, atmosConfig progress: p, dryRun: dryRun, atmosConfig: atmosConfig, - isTTY: tty, + isTTY: isTTY, }, nil } diff --git a/internal/exec/vendor_model_component.go b/internal/exec/vendor_model_component.go index 108fe56c8..0674ce095 100644 --- a/internal/exec/vendor_model_component.go +++ b/internal/exec/vendor_model_component.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/go-getter" cp "github.com/otiai10/copy" + "github.com/cloudposse/atmos/internal/tui/templates/term" "github.com/cloudposse/atmos/pkg/schema" "github.com/cloudposse/atmos/pkg/ui/theme" ) @@ -51,7 +52,7 @@ func newModelComponentVendorInternal(pkgs []pkgComponentVendor, dryRun bool, atm vendorPks = append(vendorPks, vendorPkg) } - tty := CheckTTYSupport() + tty := term.CheckTTYSupport() return modelVendor{ packages: vendorPks, spinner: s, diff --git a/internal/exec/vendor_utils.go b/internal/exec/vendor_utils.go index aa6a80c26..d0de4e9e5 100644 --- a/internal/exec/vendor_utils.go +++ b/internal/exec/vendor_utils.go @@ -15,6 +15,7 @@ import ( "github.com/spf13/cobra" "gopkg.in/yaml.v3" + "github.com/cloudposse/atmos/internal/tui/templates/term" cfg "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/schema" u "github.com/cloudposse/atmos/pkg/utils" @@ -418,7 +419,7 @@ func ExecuteAtmosVendorInternal( // Run TUI to process packages if len(packages) > 0 { var opts []tea.ProgramOption - if !CheckTTYSupport() { + if !term.CheckTTYSupport() { // set tea.WithInput(nil) workaround tea program not run on not TTY mod issue on non TTY mode https://github.com/charmbracelet/bubbletea/issues/761 opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)} u.LogWarning(atmosConfig, "No TTY detected. Falling back to basic output. This can happen when no terminal is attached or when commands are pipelined.") diff --git a/internal/tui/templates/term/term_writer.go b/internal/tui/templates/term/term_writer.go index f6ae11e51..d1a8725e8 100644 --- a/internal/tui/templates/term/term_writer.go +++ b/internal/tui/templates/term/term_writer.go @@ -4,7 +4,6 @@ import ( "io" "os" - "github.com/cloudposse/atmos/internal/exec" "github.com/mitchellh/go-wordwrap" "golang.org/x/term" ) @@ -31,7 +30,7 @@ func NewResponsiveWriter(w io.Writer) io.Writer { return w } - if !exec.CheckTTYSupport() { + if !CheckTTYSupport() { return w } @@ -78,3 +77,10 @@ func (w *TerminalWriter) Write(p []byte) (int, error) { func (w *TerminalWriter) GetWidth() uint { return w.width } + +// CheckTTYSupport checks if stdout supports TTY for displaying the progress UI. +func CheckTTYSupport() bool { + fd := int(os.Stdout.Fd()) + isTerminal := term.IsTerminal(fd) + return isTerminal +} diff --git a/pkg/list/list_workflows.go b/pkg/list/list_workflows.go index 54de87cdd..1a03c6ee4 100644 --- a/pkg/list/list_workflows.go +++ b/pkg/list/list_workflows.go @@ -10,7 +10,7 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss/table" - "github.com/cloudposse/atmos/internal/exec" + "github.com/cloudposse/atmos/internal/tui/templates/term" "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/schema" "github.com/cloudposse/atmos/pkg/ui/theme" @@ -199,7 +199,7 @@ func FilterAndListWorkflows(fileFlag string, listConfig schema.ListConfig, forma default: // If format is empty or "table", use table format - if format == "" && exec.CheckTTYSupport() { + if format == "" && term.CheckTTYSupport() { // Create a styled table for TTY t := table.New(). Border(lipgloss.ThickBorder()). From 08153a5f48385105451495934363651c8f583c73 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 26 Jan 2025 13:02:23 +0100 Subject: [PATCH 11/64] atmost about usage and workflow usage --- cmd/markdown/atmos_about_usage.md | 4 ++++ cmd/markdown/atmos_workflow_usage.md | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 cmd/markdown/atmos_about_usage.md create mode 100644 cmd/markdown/atmos_workflow_usage.md diff --git a/cmd/markdown/atmos_about_usage.md b/cmd/markdown/atmos_about_usage.md new file mode 100644 index 000000000..679c92047 --- /dev/null +++ b/cmd/markdown/atmos_about_usage.md @@ -0,0 +1,4 @@ +- Execute atmos about +``` + $ atmos about +``` \ No newline at end of file diff --git a/cmd/markdown/atmos_workflow_usage.md b/cmd/markdown/atmos_workflow_usage.md new file mode 100644 index 000000000..026d983bb --- /dev/null +++ b/cmd/markdown/atmos_workflow_usage.md @@ -0,0 +1,16 @@ +– Use interactive UI +``` +$ atmos workflow +``` +– Execute a workflow +``` +$ atmos workflow --file +``` +– Execute with stack override +``` +$ atmos workflow --file --stack +``` +– Resume from specific step +``` +$ atmos workflow --file --from-step +``` From b1cc112b346d3dd15a76901ddc61f38c7c69655f Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 26 Jan 2025 13:40:24 +0100 Subject: [PATCH 12/64] Improved flag usage example --- cmd/cmd_utils.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index c8899f9ae..88e695a93 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -569,13 +569,13 @@ func showFlagUsageAndExit(cmd *cobra.Command, err error) error { unknownCommand := fmt.Sprintf("%v for command `%s`\n\n", err.Error(), cmd.CommandPath()) args := strings.Split(err.Error(), ": ") if len(args) == 2 { - unknownCommand = fmt.Sprintf("%s `%s` for command `%s`\n\n", args[0], args[1], cmd.CommandPath()) + if strings.Contains(args[0], "flag needs an argument") { + unknownCommand = fmt.Sprintf("`%s` %s for command `%s`\n\n", args[1], args[0], cmd.CommandPath()) + } else { + unknownCommand = fmt.Sprintf("%s `%s` for command `%s`\n\n", args[0], args[1], cmd.CommandPath()) + } } - renderError(ErrorMessage{ - Title: "Invalid Flag", - Details: unknownCommand, - Suggestion: fmt.Sprintf("Run `%s --help` for usage", cmd.CommandPath()), - }) + showUsageExample(cmd, unknownCommand) os.Exit(1) return nil } @@ -603,7 +603,6 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin func showErrorExampleFromMarkdown(cmd *cobra.Command, arg string) { commandPath := cmd.CommandPath() - contentName := strings.ReplaceAll(commandPath, " ", "_") suggestions := []string{} details := fmt.Sprintf("The command `%s` is not valid\n\n", commandPath) if len(arg) > 0 { @@ -631,6 +630,11 @@ func showErrorExampleFromMarkdown(cmd *cobra.Command, arg string) { details += "No valid subcommands found for `" + cmd.CommandPath() + "`\n" } } + showUsageExample(cmd, details) +} + +func showUsageExample(cmd *cobra.Command, details string) { + contentName := strings.ReplaceAll(cmd.CommandPath(), " ", "_") suggestion := fmt.Sprintf("\nRun '%s --help' for usage", cmd.CommandPath()) if exampleContent, ok := examples[contentName]; ok { suggestion = exampleContent.Suggestion From 370e9823935ba089c06a0b9fc122f954cbb1cffa Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 26 Jan 2025 13:47:04 +0100 Subject: [PATCH 13/64] update workflow error message --- cmd/workflow.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/workflow.go b/cmd/workflow.go index c36fa17f5..d4694685c 100644 --- a/cmd/workflow.go +++ b/cmd/workflow.go @@ -77,7 +77,7 @@ var workflowCmd = &cobra.Command{ // Format common error messages if strings.Contains(err.Error(), "does not exist") { err := renderError(ErrorMessage{ - Title: "Workflow File Not Found", + Title: "File Not Found", Details: fmt.Sprintf("`%v` was not found", workflowFile), Suggestion: "", }) From 045ab1945716b5e63cd419cd31ee36b0e908ad55 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 26 Jan 2025 13:53:42 +0100 Subject: [PATCH 14/64] updated usage --- cmd/cmd_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 88e695a93..6e7e42bab 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -604,7 +604,7 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin func showErrorExampleFromMarkdown(cmd *cobra.Command, arg string) { commandPath := cmd.CommandPath() suggestions := []string{} - details := fmt.Sprintf("The command `%s` is not valid\n\n", commandPath) + details := fmt.Sprintf("The command `%s` is not valid usage\n\n", commandPath) if len(arg) > 0 { details = fmt.Sprintf("Unknown command `%s` for `%s`\n\n", arg, commandPath) } else if len(cmd.Commands()) != 0 && arg == "" { From e8fbcaf1f7d7151396093089c85de2b19ca1b455 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 19:55:51 +0100 Subject: [PATCH 15/64] Add custom alias to help --- cmd/cmd_utils.go | 35 +++++++++++++++ internal/tui/templates/base_template.go | 4 +- internal/tui/templates/templater.go | 18 ++++---- pkg/ui/markdown/renderer.go | 57 +++++++++++++------------ 4 files changed, 75 insertions(+), 39 deletions(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 6e7e42bab..dc8ec73e8 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -46,6 +46,12 @@ func processCustomCommands( var command *cobra.Command existingTopLevelCommands := make(map[string]*cobra.Command) + // Build commands and their hierarchy from the alias map + for alias, fullCmd := range atmosConfig.CommandAliases { + parts := strings.Fields(fullCmd) + addCommandWithAlias(RootCmd, alias, parts) + } + if topLevel { existingTopLevelCommands = getTopLevelCommands() } @@ -112,6 +118,35 @@ func processCustomCommands( return nil } +// addCommandWithAlias adds a command hierarchy based on the full command +func addCommandWithAlias(parentCmd *cobra.Command, alias string, parts []string) { + if len(parts) == 0 { + return + } + + // Check if a command with the current part already exists + var cmd *cobra.Command + for _, c := range parentCmd.Commands() { + if c.Use == parts[0] { + cmd = c + break + } + } + + // If the command doesn't exist, create it + if cmd == nil { + u.LogErrorAndExit(schema.AtmosConfiguration{}, fmt.Errorf("subcommand '%s' not found for alias '%s'", parts[0], alias)) + } + + // If there are more parts, recurse for the next level + if len(parts) > 1 { + addCommandWithAlias(cmd, alias, parts[1:]) + } else if !Contains(cmd.Aliases, alias) { + // This is the last part of the command, add the alias + cmd.Aliases = append(cmd.Aliases, alias) + } +} + // processCommandAliases processes the command aliases func processCommandAliases( atmosConfig schema.AtmosConfiguration, diff --git a/internal/tui/templates/base_template.go b/internal/tui/templates/base_template.go index af29a2681..b2beeaf31 100644 --- a/internal/tui/templates/base_template.go +++ b/internal/tui/templates/base_template.go @@ -27,7 +27,7 @@ func GenerateFromBaseTemplate(parts []HelpTemplateSections) string { func getSection(section HelpTemplateSections) string { switch section { case LongDescription: - return `{{ .Long }} + return `{{renderMarkdown .Long }} ` case AdditionalHelpTopics: return `{{if .HasHelpSubCommands}} @@ -61,7 +61,7 @@ func getSection(section HelpTemplateSections) string { {{HeadingStyle "Examples:"}} -{{formatExamples .Example}}{{end}}` +{{renderMarkdown .Example}}{{end}}` case Flags: return `{{if .HasAvailableLocalFlags}} diff --git a/internal/tui/templates/templater.go b/internal/tui/templates/templater.go index 3e0bc5113..3ac45c3ee 100644 --- a/internal/tui/templates/templater.go +++ b/internal/tui/templates/templater.go @@ -86,17 +86,13 @@ func isAliasesPresent(cmds []*cobra.Command) bool { return len(filterCommands(cmds, true)) > 0 } -func formatExamples(example string) string { +func renderMarkdown(example string) string { render, err := markdown.NewTerminalMarkdownRenderer(schema.AtmosConfiguration{}) if err != nil { return "" } - data, err := render.RenderError("", example, "") - if err == nil { - return data - } - data, err = render.RenderAscii(example) + data, err := render.Render(example) if err == nil { return data } @@ -132,9 +128,10 @@ func formatCommands(cmds []*cobra.Command, listType string) string { continue } case "subcommandAliases": - if cmd.Annotations["nativeCommand"] == "true" { - continue - } + // if cmd.Annotations["nativeCommand"] == "true" { + // continue + // } + if cmd.IsAvailableCommand() || cmd.Name() == "help" { availableCmds = append(availableCmds, cmd) if len(cmd.Name()) > maxLen { @@ -186,6 +183,7 @@ func SetCustomUsageFunc(cmd *cobra.Command) error { } t := &Templater{ UsageTemplate: GenerateFromBaseTemplate([]HelpTemplateSections{ + LongDescription, Usage, Aliases, AvailableCommands, @@ -203,7 +201,7 @@ func SetCustomUsageFunc(cmd *cobra.Command) error { cobra.AddTemplateFunc("isAliasesPresent", isAliasesPresent) cobra.AddTemplateFunc("isNativeCommandsAvailable", isNativeCommandsAvailable) cobra.AddTemplateFunc("formatCommands", formatCommands) - cobra.AddTemplateFunc("formatExamples", formatExamples) + cobra.AddTemplateFunc("renderMarkdown", renderMarkdown) return nil } diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index f48162b1f..9d14e5e09 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -56,7 +56,34 @@ func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Render // Render renders markdown content to ANSI styled text func (r *Renderer) Render(content string) (string, error) { - return r.renderer.Render(content) + rendered, err := r.renderer.Render(content) + if err != nil { + // If rendering fails, fallback to ASCII style + rendered, err = r.RenderAscii(content) + if err != nil { + return "", err + } + } + // Remove duplicate URLs and trailing newlines + lines := strings.Split(rendered, "\n") + var result []string + + // Create a purple style + purpleStyle := termenv.Style{}.Foreground(r.profile.Color(Purple)).Bold() + + for _, line := range lines { + trimmed := strings.TrimSpace(line) + if strings.HasPrefix(trimmed, "$") { + // Add custom styling for command examples + styled := purpleStyle.Styled(strings.TrimSpace(line)) + result = append(result, " "+styled) + } else if trimmed != "" { + result = append(result, line) + } + } + + // Add a single newline at the end plus extra spacing + return strings.Join(result, "\n"), nil } func (r *Renderer) RenderAscii(content string) (string, error) { @@ -115,31 +142,7 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error } } - rendered, err := r.Render(content) - if err != nil { - return "", err - } - - // Remove duplicate URLs and trailing newlines - lines := strings.Split(rendered, "\n") - var result []string - - // Create a purple style - purpleStyle := termenv.Style{}.Foreground(r.profile.Color(Purple)).Bold() - - for _, line := range lines { - trimmed := strings.TrimSpace(line) - if strings.HasPrefix(trimmed, "$") { - // Add custom styling for command examples - styled := purpleStyle.Styled(strings.TrimSpace(line)) - result = append(result, " "+styled) - } else if trimmed != "" { - result = append(result, line) - } - } - - // Add a single newline at the end plus extra spacing - return strings.Join(result, "\n"), nil + return r.Render(content) } // RenderSuccess renders a success message with specific styling @@ -176,7 +179,7 @@ func NewTerminalMarkdownRenderer(atmosConfig schema.AtmosConfiguration) (*Render if maxWidth > 0 { screenWidth = uint(min(maxWidth, int(wr.GetWidth()))) } - + screenWidth += 15 return NewRenderer( atmosConfig, WithWidth(screenWidth), From 3e4563e72d73ba7f7007a50c72633cef41a7025d Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 21:11:24 +0100 Subject: [PATCH 16/64] Fix asci render logic for error --- cmd/cmd_utils.go | 8 ++++---- cmd/workflow.go | 3 ++- pkg/ui/markdown/renderer.go | 7 +++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index dc8ec73e8..915b3df09 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -639,11 +639,11 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin func showErrorExampleFromMarkdown(cmd *cobra.Command, arg string) { commandPath := cmd.CommandPath() suggestions := []string{} - details := fmt.Sprintf("The command `%s` is not valid usage\n\n", commandPath) + details := fmt.Sprintf("The command `%s` is not valid usage\n", commandPath) if len(arg) > 0 { - details = fmt.Sprintf("Unknown command `%s` for `%s`\n\n", arg, commandPath) + details = fmt.Sprintf("Unknown command `%s` for `%s`\n", arg, commandPath) } else if len(cmd.Commands()) != 0 && arg == "" { - details = fmt.Sprintf("The command `%s` requires a subcommand\n\n", commandPath) + details = fmt.Sprintf("The command `%s` requires a subcommand\n", commandPath) } if len(arg) > 0 { suggestions = cmd.SuggestionsFor(arg) @@ -670,7 +670,7 @@ func showErrorExampleFromMarkdown(cmd *cobra.Command, arg string) { func showUsageExample(cmd *cobra.Command, details string) { contentName := strings.ReplaceAll(cmd.CommandPath(), " ", "_") - suggestion := fmt.Sprintf("\nRun '%s --help' for usage", cmd.CommandPath()) + suggestion := fmt.Sprintf("\n\nRun `%s --help` for usage", cmd.CommandPath()) if exampleContent, ok := examples[contentName]; ok { suggestion = exampleContent.Suggestion details += "\n## Usage Examples:\n" + exampleContent.Content diff --git a/cmd/workflow.go b/cmd/workflow.go index d4694685c..7cec6fb0c 100644 --- a/cmd/workflow.go +++ b/cmd/workflow.go @@ -30,12 +30,13 @@ func renderError(msg ErrorMessage) error { if err != nil { return err } + rendered, err := renderer.RenderError(msg.Title, msg.Details, msg.Suggestion) if err != nil { return fmt.Errorf("failed to render error message: %w", err) } - fmt.Print(rendered + "\n") + os.Stderr.WriteString(fmt.Sprint(rendered + "\n")) return nil } diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index 9d14e5e09..5c4ba0196 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -10,6 +10,7 @@ import ( "github.com/cloudposse/atmos/internal/tui/templates/term" "github.com/cloudposse/atmos/pkg/schema" "github.com/muesli/termenv" + t "golang.org/x/term" ) // Renderer is a markdown renderer using Glamour @@ -127,7 +128,7 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error var content string if title != "" { - content += fmt.Sprintf("\n# %s\n\n", title) + content += fmt.Sprintf("\n# %s\n", title) } if details != "" { @@ -141,7 +142,9 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error content += suggestion } } - + if !t.IsTerminal(int(os.Stderr.Fd())) { + return r.RenderAscii(content) + } return r.Render(content) } From d65a24e8173797a2c0695e7d84e3a654e71e006a Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 21:27:50 +0100 Subject: [PATCH 17/64] fix testcases --- ...ICommands_atmos_about_--help.stdout.golden | 7 +- ...nds_atmos_about_non-existent.stderr.golden | 12 ++- ...nds_atmos_about_non-existent.stdout.golden | 3 - ...stCLICommands_atmos_atlantis.stderr.golden | 10 +- ...stCLICommands_atmos_atlantis.stdout.golden | 4 - ...mmands_atmos_atlantis_--help.stdout.golden | 12 +-- ...ands_atmos_atlantis_generate.stderr.golden | 10 +- ...ands_atmos_atlantis_generate.stdout.golden | 4 - ...mos_atlantis_generate_--help.stdout.golden | 14 +-- ...atmos_atlantis_generate_help.stdout.golden | 14 +-- ..._generate_repo-config_--help.stdout.golden | 13 +-- ...is_generate_repo-config_help.stdout.golden | 13 +-- ...ate_repo-config_non-existant.stderr.golden | 8 +- ...ate_repo-config_non-existant.stdout.golden | 3 - ...Commands_atmos_atlantis_help.stdout.golden | 12 +-- ...stCLICommands_atmos_helmfile.stderr.golden | 14 ++- ...stCLICommands_atmos_helmfile.stdout.golden | 8 -- ...mmands_atmos_helmfile_--help.stdout.golden | 13 ++- ..._atmos_helmfile_apply_--help.stdout.golden | 14 +-- ...ds_atmos_helmfile_apply_help.stdout.golden | 14 +-- ...Commands_atmos_helmfile_help.stdout.golden | 13 ++- ..._atmos_helmfile_non-existant.stderr.golden | 14 ++- ..._atmos_helmfile_non-existant.stdout.golden | 8 -- ...ICommands_atmos_non-existent.stderr.golden | 27 ++++- ...ICommands_atmos_non-existent.stdout.golden | 21 ---- ...tCLICommands_atmos_terraform.stderr.golden | 48 ++++++++- ...tCLICommands_atmos_terraform.stdout.golden | 34 ------ ...mands_atmos_terraform_--help.stderr.golden | 0 ...mands_atmos_terraform_--help.stdout.golden | 101 ++++++++++++++++++ ...atmos_terraform_apply_--help.stdout.golden | 21 ++-- ...s_atmos_terraform_apply_help.stdout.golden | 21 ++-- ...ommands_atmos_terraform_help.stdout.golden | 10 +- ...atmos_terraform_non-existent.stderr.golden | 49 ++++++++- ...atmos_terraform_non-existent.stdout.golden | 35 ------ ...validate_editorconfig_--help.stdout.golden | 7 +- ...s_validate_editorconfig_help.stdout.golden | 7 +- ...te_editorconfig_non-existant.stderr.golden | 8 +- ...te_editorconfig_non-existant.stdout.golden | 3 - ...rsion_--check_--non-existent.stderr.golden | 8 +- ...rsion_--check_--non-existent.stdout.golden | 1 - tests/test-cases/help-and-usage.yaml | 99 +---------------- 41 files changed, 396 insertions(+), 341 deletions(-) create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_--help.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden diff --git a/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden index 789ed6cf9..04e1ce131 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden @@ -1,4 +1,5 @@ +Display information about Atmos, its features, and benefits. Usage: @@ -28,9 +29,3 @@ Global Flags: standard file descriptor (including '/dev/null'): atmos --redirect-stderr /dev/stdout - -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. - -Example: - atmos about -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden index 961c3bb7b..c027c7d0b 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden @@ -1,2 +1,12 @@ -Error: Unknown command "non-existent" for "atmos about" + +# Incorrect Usage + +Unknown command non-existent for atmos about No valid subcommands found for atmos about + +## Usage Examples: + +• Execute atmos about + + $ atmos about + diff --git a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stdout.golden b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stdout.golden index a8a285014..e69de29bb 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stdout.golden @@ -1,3 +0,0 @@ -No valid subcommands found - -Run 'atmos about --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden index b0f3d7c05..137bfcd24 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden @@ -1,2 +1,10 @@ -Error: Unknown command: "atmos atlantis" + +# Incorrect Usage + +The command atmos atlantis requires a subcommand Valid subcommands are: + +• generate + +Run atmos atlantis --help for usage + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis.stdout.golden index 8ea0d8b15..e69de29bb 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis.stdout.golden @@ -1,4 +0,0 @@ -Valid subcommands are: - generate - -Run 'atmos atlantis --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden index d557b25c4..ba32cc168 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden @@ -1,4 +1,5 @@ +Generate and manage Atlantis configurations that use Atmos under the hood to run Terraform workflows, bringing the power of Atmos to Atlantis for streamlined infrastructure automation. Usage: @@ -12,6 +13,10 @@ Available Commands: Flags: + -- Double dashes 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. (default "false") + -h, --help help for atlantis (default "false") @@ -34,11 +39,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -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. - -Example: - atmos atlantis [subcommand] -s -- - - Use "atmos atlantis [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden index fc2b39593..bf05f232d 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden @@ -1,2 +1,10 @@ -Error: Unknown command: "atmos atlantis generate" + +# Incorrect Usage + +The command atmos atlantis generate requires a subcommand Valid subcommands are: + +• repo-config + +Run atmos atlantis generate --help for usage + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stdout.golden index 51dd84584..e69de29bb 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stdout.golden @@ -1,4 +0,0 @@ -Valid subcommands are: - repo-config - -Run 'atmos atlantis generate --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden index 68a1188ec..30364480d 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden @@ -1,4 +1,5 @@ +This command generates configuration files to automate and streamline Terraform workflows with Atlantis. Usage: @@ -28,6 +29,12 @@ Flags: Global Flags: + -- Double dashes 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. (default + "false") + --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file descriptor, including '/dev/stdout', @@ -45,11 +52,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -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. - -Example: - atmos atlantis generate [subcommand] -s -- - - Use "atmos atlantis generate [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden index 68a1188ec..30364480d 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden @@ -1,4 +1,5 @@ +This command generates configuration files to automate and streamline Terraform workflows with Atlantis. Usage: @@ -28,6 +29,12 @@ Flags: Global Flags: + -- Double dashes 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. (default + "false") + --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file descriptor, including '/dev/stdout', @@ -45,11 +52,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -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. - -Example: - atmos atlantis generate [subcommand] -s -- - - Use "atmos atlantis generate [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden index 6df1042ce..e35683908 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden @@ -1,4 +1,5 @@ +Generate the repository configuration file required for Atlantis to manage Terraform repositories. Usage: @@ -102,6 +103,12 @@ Flags: Global Flags: + -- Double dashes 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. (default + "false") + --clone-target-ref Clone the target reference with which to compare the current branch: atmos atlantis generate repo-config --affected-only=true @@ -131,9 +138,3 @@ Global Flags: standard file descriptor (including '/dev/null'): atmos --redirect-stderr /dev/stdout - -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. - -Example: - atmos atlantis generate repo-config -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden index 6df1042ce..e35683908 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden @@ -1,4 +1,5 @@ +Generate the repository configuration file required for Atlantis to manage Terraform repositories. Usage: @@ -102,6 +103,12 @@ Flags: Global Flags: + -- Double dashes 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. (default + "false") + --clone-target-ref Clone the target reference with which to compare the current branch: atmos atlantis generate repo-config --affected-only=true @@ -131,9 +138,3 @@ Global Flags: standard file descriptor (including '/dev/null'): atmos --redirect-stderr /dev/stdout - -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. - -Example: - atmos atlantis generate repo-config -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden index 9a5366b58..491a79aac 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden @@ -1,2 +1,8 @@ -Error: Unknown command "non-existant" for "atmos atlantis generate repo-config" + +# Incorrect Usage + +Unknown command non-existant for atmos atlantis generate repo-config No valid subcommands found for atmos atlantis generate repo-config + +Run atmos atlantis generate repo-config --help for usage + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stdout.golden index 418a741ad..e69de29bb 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stdout.golden @@ -1,3 +0,0 @@ -No valid subcommands found - -Run 'atmos atlantis generate repo-config --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden index d557b25c4..ba32cc168 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden @@ -1,4 +1,5 @@ +Generate and manage Atlantis configurations that use Atmos under the hood to run Terraform workflows, bringing the power of Atmos to Atlantis for streamlined infrastructure automation. Usage: @@ -12,6 +13,10 @@ Available Commands: Flags: + -- Double dashes 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. (default "false") + -h, --help help for atlantis (default "false") @@ -34,11 +39,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -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. - -Example: - atmos atlantis [subcommand] -s -- - - Use "atmos atlantis [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden index 9334d903c..4be5986e7 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden @@ -1,2 +1,14 @@ -Error: Unknown command: "atmos helmfile" + +# Incorrect Usage + +The command atmos helmfile requires a subcommand Valid subcommands are: + +• apply +• destroy +• diff +• generate +• sync + +Run atmos helmfile --help for usage + diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile.stdout.golden index 38666a97e..e69de29bb 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile.stdout.golden @@ -1,8 +0,0 @@ -Valid subcommands are: - apply - destroy - diff - generate - sync - -Run 'atmos helmfile --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden index 37158506a..c56ab3926 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden @@ -1,4 +1,5 @@ +This command runs Helmfile commands to manage Kubernetes deployments using Helmfile. Usage: @@ -20,6 +21,11 @@ Available Commands: Flags: + -- Double dashes 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. (default "false") + -h, --help help for helmfile (default "false") -s, --stack string atmos helmfile -s @@ -45,11 +51,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -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. - -Example: - atmos helmfile [subcommand] -s -- - - Use "atmos helmfile [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden index bb3fe72a5..ad503b23a 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden @@ -1,4 +1,6 @@ +This command reconciles the actual state of Helm releases in the cluster with the desired state defined in your configurations by applying the necessary changes. +Example usage: atmos helmfile apply echo-server -s tenant1-ue2-dev atmos helmfile apply echo-server -s tenant1-ue2-dev --redirect-stderr /dev/stdout Usage: @@ -12,6 +14,12 @@ Flags: Global Flags: + -- Double dashes 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. (default + "false") + --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file descriptor, including '/dev/stdout', @@ -31,9 +39,3 @@ Global Flags: -s, --stack string atmos helmfile -s - -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. - -Example: - atmos helmfile apply -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden index bb3fe72a5..ad503b23a 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden @@ -1,4 +1,6 @@ +This command reconciles the actual state of Helm releases in the cluster with the desired state defined in your configurations by applying the necessary changes. +Example usage: atmos helmfile apply echo-server -s tenant1-ue2-dev atmos helmfile apply echo-server -s tenant1-ue2-dev --redirect-stderr /dev/stdout Usage: @@ -12,6 +14,12 @@ Flags: Global Flags: + -- Double dashes 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. (default + "false") + --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file descriptor, including '/dev/stdout', @@ -31,9 +39,3 @@ Global Flags: -s, --stack string atmos helmfile -s - -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. - -Example: - atmos helmfile apply -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden index 37158506a..c56ab3926 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden @@ -1,4 +1,5 @@ +This command runs Helmfile commands to manage Kubernetes deployments using Helmfile. Usage: @@ -20,6 +21,11 @@ Available Commands: Flags: + -- Double dashes 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. (default "false") + -h, --help help for helmfile (default "false") -s, --stack string atmos helmfile -s @@ -45,11 +51,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -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. - -Example: - atmos helmfile [subcommand] -s -- - - Use "atmos helmfile [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden index a1ba4f1a1..ec7030b80 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden @@ -1,2 +1,14 @@ -Error: Unknown command "non-existant" for "atmos helmfile" + +# Incorrect Usage + +Unknown command non-existant for atmos helmfile Valid subcommands are: + +• apply +• destroy +• diff +• generate +• sync + +Run atmos helmfile --help for usage + diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stdout.golden index 38666a97e..e69de29bb 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stdout.golden @@ -1,8 +0,0 @@ -Valid subcommands are: - apply - destroy - diff - generate - sync - -Run 'atmos helmfile --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden index 76adc7c0e..a13af7244 100644 --- a/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden @@ -1,2 +1,27 @@ -Error: Unknown command "non-existent" for "atmos" + +# Incorrect Usage + +Unknown command non-existent for atmos Valid subcommands are: + +• about +• atlantis +• aws +• completion +• describe +• docs +• helmfile +• help +• list +• pro +• show +• support +• terraform +• tf +• validate +• vendor +• version +• workflow + +Run atmos --help for usage + diff --git a/tests/snapshots/TestCLICommands_atmos_non-existent.stdout.golden b/tests/snapshots/TestCLICommands_atmos_non-existent.stdout.golden index 5d3c0b07f..e69de29bb 100644 --- a/tests/snapshots/TestCLICommands_atmos_non-existent.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_non-existent.stdout.golden @@ -1,21 +0,0 @@ -Valid subcommands are: - about - atlantis - aws - completion - describe - docs - helmfile - help - list - pro - show - support - terraform - tf - validate - vendor - version - workflow - -Run 'atmos --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden index 1b53ce83a..be42844a1 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden @@ -1,2 +1,48 @@ -Error: Unknown command: "atmos terraform" + +# Incorrect Usage + +The command atmos terraform requires a subcommand Valid subcommands are: + +• apply +• clean +• console +• deploy +• destroy +• fmt +• force-unlock +• generate +• get +• graph +• import +• init +• login +• logout +• metadata +• modules +• output +• plan +• providers +• refresh +• shell +• show +• state +• taint +• test +• untaint +• validate +• varfile +• version +• workspace +• write + +## Usage Examples: + +Examples: + +– Execute a terraform + + $ atmos terraform [sub-command] -s + +For more information, refer to the docs https://atmos.tools/cli/commands/terraform/usage + diff --git a/tests/snapshots/TestCLICommands_atmos_terraform.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform.stdout.golden index e2de0a1d0..e69de29bb 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform.stdout.golden @@ -1,34 +0,0 @@ -Valid subcommands are: - apply - clean - console - deploy - destroy - fmt - force-unlock - generate - get - graph - import - init - login - logout - metadata - modules - output - plan - providers - refresh - shell - show - state - taint - test - untaint - validate - varfile - version - workspace - write - -Run 'atmos terraform --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden new file mode 100644 index 000000000..47aeb841d --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden @@ -0,0 +1,101 @@ + +This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management. + +Usage: + + atmos terraform [sub-command] [flags] + +Aliases: + + terraform, tf + + +Available Commands: + + clean Clean up Terraform state and artifacts. + deploy Deploy the specified infrastructure using Terraform + generate Generate Terraform configuration files for Atmos components and stacks. + shell Configure an environment for an Atmos component and start a new shell. + varfile Load variables from a file + write Write variables to a file + +Native terraform Commands: + + apply Apply changes to infrastructure + console Try Terraform expressions at an interactive command prompt + destroy Destroy previously-created infrastructure + fmt Reformat your configuration in the standard style + force-unlock Release a stuck lock on the current workspace + get Install or upgrade remote Terraform modules + graph Generate a Graphviz graph of the steps in an operation + import Import existing infrastructure into Terraform state. + init Prepare your working directory for other commands + login Obtain and save credentials for a remote host + logout Remove locally-stored credentials for a remote host + metadata Metadata related commands + modules Show all declared modules in a working directory + output Show output values from your root module + plan Show changes required by the current configuration + providers Show the providers required for this configuration + refresh Update the state to match remote systems + show Show the current state or a saved plan + state Advanced state management + taint Mark a resource instance as not fully functional + test Execute integration tests for Terraform modules + untaint Remove the 'tainted' state from a resource instance + validate Check whether the configuration is valid + version Show the current Terraform version + workspace Manage Terraform workspaces + + +Flags: + + -- Double dashes 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. (default "false") + + --append-user-agent string Sets the TF_APPEND_USER_AGENT environment + variable to customize the User-Agent + string in Terraform provider requests. + Example: 'Atmos/%s (Cloud Posse; + +https://atmos.tools)'. This flag works + with almost all commands. + + -h, --help help for terraform (default "false") + + --skip-init Skip running 'terraform init' before + executing the command (default "false") + + -s, --stack string atmos terraform + -s + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + + +Examples: + +Examples: +– Execute a terraform + $ atmos terraform [sub-command] -s  + +Use "atmos terraform [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden index 50dac239e..511b6a139 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden @@ -1,15 +1,11 @@ +Apply the changes required to reach the desired state of the configuration. This will prompt for confirmation before making changes. Usage: atmos terraform apply [flags] -Examples: - -atmos terraform apply -s - - Flags: --from-plan If set atmos will use the previously generated plan @@ -22,6 +18,12 @@ Flags: Global Flags: + -- Double dashes 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. (default "false") + --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. @@ -52,8 +54,9 @@ Global Flags: -s, --stack string atmos terraform -s -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. -Example: - atmos terraform apply -s -- +Examples: + +Examples: +– Execute a terraform apply + $ atmos terraform apply -s  diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden index 50dac239e..511b6a139 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden @@ -1,15 +1,11 @@ +Apply the changes required to reach the desired state of the configuration. This will prompt for confirmation before making changes. Usage: atmos terraform apply [flags] -Examples: - -atmos terraform apply -s - - Flags: --from-plan If set atmos will use the previously generated plan @@ -22,6 +18,12 @@ Flags: Global Flags: + -- Double dashes 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. (default "false") + --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. @@ -52,8 +54,9 @@ Global Flags: -s, --stack string atmos terraform -s -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. -Example: - atmos terraform apply -s -- +Examples: + +Examples: +– Execute a terraform apply + $ atmos terraform apply -s  diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index 65db538ee..47aeb841d 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -1,4 +1,5 @@ +This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management. Usage: @@ -93,11 +94,8 @@ Global Flags: Examples: -– Execute a terraform - -``` - $ atmos terraform [sub-command] -s -``` - +Examples: +– Execute a terraform + $ atmos terraform [sub-command] -s  Use "atmos terraform [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden index 7615a96b2..d7746f072 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden @@ -1,2 +1,49 @@ -Error: Unknown command "non-existent" for "atmos terraform" + +# Incorrect Usage + +Unknown command non-existent for atmos terraform Valid subcommands are: + +• apply +• clean +• console +• deploy +• destroy +• fmt +• force-unlock +• generate +• get +• graph +• import +• init +• login +• logout +• metadata +• modules +• output +• plan +• providers +• provision +• refresh +• shell +• show +• state +• taint +• test +• untaint +• validate +• varfile +• version +• workspace +• write + +## Usage Examples: + +Examples: + +– Execute a terraform + + $ atmos terraform [sub-command] -s + +For more information, refer to the docs https://atmos.tools/cli/commands/terraform/usage + diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stdout.golden index 1634bdb72..e69de29bb 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stdout.golden @@ -1,35 +0,0 @@ -Valid subcommands are: - apply - clean - console - deploy - destroy - fmt - force-unlock - generate - get - graph - import - init - login - logout - metadata - modules - output - plan - providers - provision - refresh - shell - show - state - taint - test - untaint - validate - varfile - version - workspace - write - -Run 'atmos terraform --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden index 84ea75b6e..9bd23d9ec 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden @@ -1,4 +1,5 @@ +Validate all files against the project's EditorConfig rules Usage: @@ -70,9 +71,3 @@ Global Flags: standard file descriptor (including '/dev/null'): atmos --redirect-stderr /dev/stdout - -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. - -Example: - atmos validate editorconfig -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden index 84ea75b6e..9bd23d9ec 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden @@ -1,4 +1,5 @@ +Validate all files against the project's EditorConfig rules Usage: @@ -70,9 +71,3 @@ Global Flags: standard file descriptor (including '/dev/null'): atmos --redirect-stderr /dev/stdout - -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. - -Example: - atmos validate editorconfig -s -- diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden index 495920047..6a81e5a92 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden @@ -1,2 +1,8 @@ -Error: Unknown command "non-existant" for "atmos validate editorconfig" + +# Incorrect Usage + +Unknown command non-existant for atmos validate editorconfig No valid subcommands found for atmos validate editorconfig + +Run atmos validate editorconfig --help for usage + diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stdout.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stdout.golden index a26882725..e69de29bb 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stdout.golden @@ -1,3 +0,0 @@ -No valid subcommands found - -Run 'atmos validate editorconfig --help' for usage diff --git a/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden index d263306ef..342c954b2 100644 --- a/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden @@ -1,2 +1,8 @@ -Error: unknown flag: --non-existent for command "atmos version" + +# Incorrect Usage + +unknown flag --non-existent for command atmos version + +Run atmos version --help for usage + diff --git a/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stdout.golden b/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stdout.golden index 0de83c6e1..e69de29bb 100644 --- a/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stdout.golden @@ -1 +0,0 @@ -Run 'atmos version --help' for usage diff --git a/tests/test-cases/help-and-usage.yaml b/tests/test-cases/help-and-usage.yaml index 2e387e9a2..c10a3e411 100644 --- a/tests/test-cases/help-and-usage.yaml +++ b/tests/test-cases/help-and-usage.yaml @@ -8,8 +8,6 @@ tests: args: - "non-existent" expect: - stderr: - - 'Error: Unknown command \"non-existent\" for \"atmos\"' exit_code: 1 - name: atmos terraform enabled: true @@ -20,13 +18,6 @@ tests: args: - "terraform" expect: - stdout: - - "Valid subcommands are:" - - "apply" - - "clean" - - "console" - stderr: - - "Error: Unknown command: \"atmos terraform\"" exit_code: 1 - name: atmos terraform help enabled: true @@ -43,14 +34,10 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "\\bapply\\b" - - "\\bgenerate\\b" - stderr: - - "^$" exit_code: 0 - name: atmos terraform --help enabled: true + snapshot: true description: "Ensure atmos terraform --help shows help output" workdir: "./" command: "atmos" @@ -58,11 +45,6 @@ tests: - "terraform" - "--help" expect: - stdout: - - "\\bapply\\b" - - "\\bgenerate\\b" - stderr: - - "^$" exit_code: 0 - name: atmos terraform apply --help enabled: true @@ -80,12 +62,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "\\bUsage\\b" - - "Flags:" - - "and the beginning of additional native arguments and flags for the specific command being run" - stderr: - - "^$" exit_code: 0 - name: atmos terraform apply help enabled: true @@ -103,12 +79,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "\\bUsage\\b" - - "Flags:" - - "and the beginning of additional native arguments and flags for the specific command being run" - stderr: - - "^$" exit_code: 0 - name: atmos terraform non-existent enabled: true @@ -120,8 +90,6 @@ tests: - "terraform" - "non-existent" expect: - stderr: - - 'Error: Unknown command \"non-existent\" for \"atmos terraform\"' exit_code: 1 - name: atmos terraform plan non-existent in non workspace enabled: true @@ -134,9 +102,6 @@ tests: - "plan" - "non-existent" expect: - stdout: - - "CLI config file specifies the directory for Atmos stack" - - "Quick Start" exit_code: 1 - name: atmos terraform plan non-existent in workspace enabled: true @@ -149,8 +114,6 @@ tests: - "plan" - "non-existent" expect: - stderr: - - "'stack' is required. Usage: atmos terraform -s " exit_code: 1 - name: atmos helmfile enabled: true @@ -161,12 +124,6 @@ tests: args: - "helmfile" expect: - stderr: - - "Error: Unknown command: \"atmos helmfile\"" - stdout: - - "Valid subcommands are:" - - "apply" - - "destroy" exit_code: 1 - name: atmos helmfile non-existant enabled: true @@ -178,12 +135,6 @@ tests: - "helmfile" - "non-existant" expect: - stderr: - - "Error: Unknown command \"non-existant\" for \"atmos helmfile\"" - stdout: - - "Valid subcommands are:" - - "apply" - - "destroy" exit_code: 1 - name: atmos helmfile help enabled: true @@ -200,10 +151,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "Available Commands:" - - "apply" - - "destroy" exit_code: 0 - name: atmos helmfile --help enabled: true @@ -220,10 +167,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "Available Commands:" - - "apply" - - "destroy" exit_code: 0 - name: atmos helmfile apply non-existant enabled: true @@ -236,9 +179,6 @@ tests: - "apply" - "non-existent" expect: - stdout: - - "CLI config file specifies the directory for Atmos stack" - - "Quick Start" exit_code: 1 - name: atmos helmfile apply enabled: true @@ -250,8 +190,6 @@ tests: - "helmfile" - "apply" expect: - stderr: - - "'stack' is required. Usage: atmos helmfile -s " exit_code: 1 - name: atmos helmfile apply help enabled: true @@ -269,9 +207,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "Flags:" - - "--logs-file" exit_code: 0 - name: atmos helmfile apply --help enabled: true @@ -289,9 +224,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "Flags:" - - "--logs-file" exit_code: 0 - name: atmos atlantis enabled: true @@ -302,8 +234,6 @@ tests: args: - "atlantis" expect: - stderr: - - "Error: Unknown command: \"atmos atlantis\"" exit_code: 1 - name: atmos atlantis help enabled: true @@ -320,9 +250,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "Available Commands:" - - "generate" exit_code: 0 - name: atmos atlantis --help enabled: true @@ -339,9 +266,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "Available Commands:" - - "generate" exit_code: 0 - name: atmos atlantis generate @@ -354,8 +278,6 @@ tests: - "atlantis" - "generate" expect: - stderr: - - "Error: Unknown command: \"atmos atlantis generate\"" exit_code: 1 - name: atmos atlantis generate help enabled: true @@ -373,9 +295,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "Available Commands:" - - "repo-config" exit_code: 0 - name: atmos atlantis generate --help enabled: true @@ -393,9 +312,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "Available Commands:" - - "repo-config" exit_code: 0 - name: atmos atlantis generate repo-config enabled: true @@ -413,11 +329,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "atmos.yaml CLI config file specifies the directory for Atmos stacks as stacks," - - "To configure and start using Atmos, refer to the following documents:" - stderr: - - "^$" exit_code: 1 - name: atmos atlantis generate repo-config help enabled: true @@ -436,12 +347,6 @@ tests: - "Update available!" - "Atmos Releases:" - "Install Atmos:" - stdout: - - "Flags:" - - "--affected-only" - - "--config-template" - stderr: - - "^$" exit_code: 0 - name: atmos atlantis generate repo-config --help enabled: true @@ -479,8 +384,6 @@ tests: - "repo-config" - "non-existant" expect: - stderr: - - "Error: Unknown command \"non-existant\" for \"atmos atlantis generate repo-config\"" exit_code: 1 - name: atmos validate editorconfig help enabled: true From 9731347bd647ceffead97c4eb0659e9b568a3433 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 21:46:23 +0100 Subject: [PATCH 18/64] test updated --- tests/snapshots/TestCLICommands_atmos_--help.stdout.golden | 2 +- ...estCLICommands_check_atmos_--help_in_empty-dir.stdout.golden | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden index 398fe56f1..b0043fd1f 100644 --- a/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden @@ -1,4 +1,5 @@ +Atmos is a universal tool for DevOps and cloud automation used for provisioning, managing and orchestrating workflows across various toolchains Usage: @@ -52,5 +53,4 @@ Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout - Use "atmos [subcommand] --help" for more information about a command. diff --git a/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden b/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden index 398fe56f1..b0043fd1f 100644 --- a/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden +++ b/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden @@ -1,4 +1,5 @@ +Atmos is a universal tool for DevOps and cloud automation used for provisioning, managing and orchestrating workflows across various toolchains Usage: @@ -52,5 +53,4 @@ Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout - Use "atmos [subcommand] --help" for more information about a command. From f801cff374c2d6de9b04582e152d8c276156de91 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 22:28:38 +0100 Subject: [PATCH 19/64] Add --help suggestion to help --- internal/tui/templates/base_template.go | 5 +++-- internal/tui/templates/templater.go | 18 ++++++++++++++++++ .../TestCLICommands_atmos_--help.stdout.golden | 2 +- ...LICommands_atmos_about_--help.stdout.golden | 2 ++ ...ommands_atmos_atlantis_--help.stdout.golden | 2 +- ...tmos_atlantis_generate_--help.stdout.golden | 2 +- ..._atmos_atlantis_generate_help.stdout.golden | 2 +- ...s_generate_repo-config_--help.stdout.golden | 2 ++ ...tis_generate_repo-config_help.stdout.golden | 2 ++ ...ICommands_atmos_atlantis_help.stdout.golden | 2 +- ...ommands_atmos_helmfile_--help.stdout.golden | 2 +- ...s_atmos_helmfile_apply_--help.stdout.golden | 2 ++ ...nds_atmos_helmfile_apply_help.stdout.golden | 2 ++ ...ICommands_atmos_helmfile_help.stdout.golden | 7 ++++++- ...mmands_atmos_terraform_--help.stdout.golden | 2 +- ..._atmos_terraform_apply_--help.stdout.golden | 2 ++ ...ds_atmos_terraform_apply_help.stdout.golden | 2 ++ ...Commands_atmos_terraform_help.stdout.golden | 2 +- ..._validate_editorconfig_--help.stdout.golden | 2 ++ ...os_validate_editorconfig_help.stdout.golden | 2 ++ ...eck_atmos_--help_in_empty-dir.stdout.golden | 2 +- 21 files changed, 54 insertions(+), 12 deletions(-) diff --git a/internal/tui/templates/base_template.go b/internal/tui/templates/base_template.go index b2beeaf31..39f46f4f8 100644 --- a/internal/tui/templates/base_template.go +++ b/internal/tui/templates/base_template.go @@ -89,8 +89,9 @@ func getSection(section HelpTemplateSections) string { {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} {{.CommandPath}} [sub-command] [flags]{{end}}` case Footer: - return `{{if .HasAvailableSubCommands}} -Use "{{.CommandPath}} {{if gt (len .Commands) 0}}[subcommand]{{end}} --help" for more information about a command.{{end}}` + return ` + +{{renderHelpMarkdown .}}` default: return "" } diff --git a/internal/tui/templates/templater.go b/internal/tui/templates/templater.go index 3ac45c3ee..7e1ed224b 100644 --- a/internal/tui/templates/templater.go +++ b/internal/tui/templates/templater.go @@ -73,6 +73,23 @@ func filterCommands(commands []*cobra.Command, returnOnlyAliases bool) []*cobra. return filtered } +func renderHelpMarkdown(cmd *cobra.Command) string { + render, err := markdown.NewTerminalMarkdownRenderer(schema.AtmosConfiguration{}) + if err != nil { + return "" + } + commandPath := cmd.CommandPath() + if cmd.HasSubCommands() { + commandPath += " [subcommand]" + } + help := fmt.Sprintf("Use `%s --help` for more information about a command.", commandPath) + data, err := render.Render(help) + if err == nil { + return data + } + return "" +} + func isNativeCommandsAvailable(cmds []*cobra.Command) bool { for _, cmd := range cmds { if cmd.Annotations["nativeCommand"] == "true" { @@ -202,6 +219,7 @@ func SetCustomUsageFunc(cmd *cobra.Command) error { cobra.AddTemplateFunc("isNativeCommandsAvailable", isNativeCommandsAvailable) cobra.AddTemplateFunc("formatCommands", formatCommands) cobra.AddTemplateFunc("renderMarkdown", renderMarkdown) + cobra.AddTemplateFunc("renderHelpMarkdown", renderHelpMarkdown) return nil } diff --git a/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden index b0043fd1f..1e5eb9962 100644 --- a/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden @@ -53,4 +53,4 @@ Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use "atmos [subcommand] --help" for more information about a command. +Use  atmos [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden index 04e1ce131..9812f2d12 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden @@ -29,3 +29,5 @@ Global Flags: standard file descriptor (including '/dev/null'): atmos --redirect-stderr /dev/stdout + +Use  atmos about --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden index ba32cc168..01a2be212 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden @@ -39,4 +39,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use "atmos atlantis [subcommand] --help" for more information about a command. +Use  atmos atlantis [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden index 30364480d..f9acecf0b 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden @@ -52,4 +52,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use "atmos atlantis generate [subcommand] --help" for more information about a command. +Use  atmos atlantis generate [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden index 30364480d..f9acecf0b 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden @@ -52,4 +52,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use "atmos atlantis generate [subcommand] --help" for more information about a command. +Use  atmos atlantis generate [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden index e35683908..363e09f02 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden @@ -138,3 +138,5 @@ Global Flags: standard file descriptor (including '/dev/null'): atmos --redirect-stderr /dev/stdout + +Use  atmos atlantis generate repo-config --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden index e35683908..363e09f02 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden @@ -138,3 +138,5 @@ Global Flags: standard file descriptor (including '/dev/null'): atmos --redirect-stderr /dev/stdout + +Use  atmos atlantis generate repo-config --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden index ba32cc168..01a2be212 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden @@ -39,4 +39,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use "atmos atlantis [subcommand] --help" for more information about a command. +Use  atmos atlantis [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden index c56ab3926..246743a0c 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden @@ -51,4 +51,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use "atmos helmfile [subcommand] --help" for more information about a command. +Use  atmos helmfile [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden index ad503b23a..ec5a5e40c 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden @@ -39,3 +39,5 @@ Global Flags: -s, --stack string atmos helmfile -s + +Use  atmos helmfile apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden index ad503b23a..ec5a5e40c 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden @@ -39,3 +39,5 @@ Global Flags: -s, --stack string atmos helmfile -s + +Use  atmos helmfile apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden index c56ab3926..e760e8b4f 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden @@ -51,4 +51,9 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use "atmos helmfile [subcommand] --help" for more information about a command. +Use  atmos helmfile [subcommand] --help for more information about a command. +╭──────────────────────────────────────────────────────────────╮ +│ Update available! 0.0.1 » 1.156.0 │ +│ Atmos Releases: https://github.com/cloudposse/atmos/releases │ +│ Install Atmos: https://atmos.tools/install │ +╰──────────────────────────────────────────────────────────────╯ diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden index 47aeb841d..baa6460f2 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden @@ -98,4 +98,4 @@ Examples: – Execute a terraform $ atmos terraform [sub-command] -s  -Use "atmos terraform [subcommand] --help" for more information about a command. +Use  atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden index 511b6a139..28c69b7d0 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden @@ -60,3 +60,5 @@ Examples: Examples: – Execute a terraform apply $ atmos terraform apply -s  + +Use  atmos terraform apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden index 511b6a139..28c69b7d0 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden @@ -60,3 +60,5 @@ Examples: Examples: – Execute a terraform apply $ atmos terraform apply -s  + +Use  atmos terraform apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index 47aeb841d..baa6460f2 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -98,4 +98,4 @@ Examples: – Execute a terraform $ atmos terraform [sub-command] -s  -Use "atmos terraform [subcommand] --help" for more information about a command. +Use  atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden index 9bd23d9ec..0f653d129 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden @@ -71,3 +71,5 @@ Global Flags: standard file descriptor (including '/dev/null'): atmos --redirect-stderr /dev/stdout + +Use  atmos validate editorconfig --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden index 9bd23d9ec..0f653d129 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden @@ -71,3 +71,5 @@ Global Flags: standard file descriptor (including '/dev/null'): atmos --redirect-stderr /dev/stdout + +Use  atmos validate editorconfig --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden b/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden index b0043fd1f..1e5eb9962 100644 --- a/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden +++ b/tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden @@ -53,4 +53,4 @@ Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use "atmos [subcommand] --help" for more information about a command. +Use  atmos [subcommand] --help for more information about a command. From 2ecd83aadd21cca320f80d206622eed9018740b3 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 22:35:34 +0100 Subject: [PATCH 20/64] removed examples from md --- cmd/markdown/atmos_terraform_apply_usage.md | 4 +--- cmd/markdown/atmos_terraform_plan_usage.md | 4 +--- cmd/markdown/atmos_terraform_usage.md | 4 +--- .../TestCLICommands_atmos_helmfile_help.stdout.golden | 5 ----- .../snapshots/TestCLICommands_atmos_terraform.stderr.golden | 2 -- .../TestCLICommands_atmos_terraform_--help.stdout.golden | 1 - ...estCLICommands_atmos_terraform_apply_--help.stdout.golden | 1 - .../TestCLICommands_atmos_terraform_apply_help.stdout.golden | 1 - .../TestCLICommands_atmos_terraform_help.stdout.golden | 1 - ...estCLICommands_atmos_terraform_non-existent.stderr.golden | 2 -- 10 files changed, 3 insertions(+), 22 deletions(-) diff --git a/cmd/markdown/atmos_terraform_apply_usage.md b/cmd/markdown/atmos_terraform_apply_usage.md index efab0725d..3abda58e3 100644 --- a/cmd/markdown/atmos_terraform_apply_usage.md +++ b/cmd/markdown/atmos_terraform_apply_usage.md @@ -1,6 +1,4 @@ -Examples: - - – Execute a terraform apply +– Execute a terraform apply ``` $ atmos terraform apply -s diff --git a/cmd/markdown/atmos_terraform_plan_usage.md b/cmd/markdown/atmos_terraform_plan_usage.md index 12929a77f..c69e5af05 100644 --- a/cmd/markdown/atmos_terraform_plan_usage.md +++ b/cmd/markdown/atmos_terraform_plan_usage.md @@ -1,6 +1,4 @@ -Examples: - - – Execute a terraform plan +– Execute a terraform plan ``` $ atmos terraform plan -s diff --git a/cmd/markdown/atmos_terraform_usage.md b/cmd/markdown/atmos_terraform_usage.md index 502c7abb5..9a13928ec 100644 --- a/cmd/markdown/atmos_terraform_usage.md +++ b/cmd/markdown/atmos_terraform_usage.md @@ -1,6 +1,4 @@ -Examples: - - – Execute a terraform +– Execute a terraform ``` $ atmos terraform [sub-command] -s diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden index e760e8b4f..246743a0c 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden @@ -52,8 +52,3 @@ Global Flags: --redirect-stderr /dev/stdout Use  atmos helmfile [subcommand] --help for more information about a command. -╭──────────────────────────────────────────────────────────────╮ -│ Update available! 0.0.1 » 1.156.0 │ -│ Atmos Releases: https://github.com/cloudposse/atmos/releases │ -│ Install Atmos: https://atmos.tools/install │ -╰──────────────────────────────────────────────────────────────╯ diff --git a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden index be42844a1..256b6fa88 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden @@ -37,8 +37,6 @@ The command atmos terraform requires a subcommand Valid subcommands are: ## Usage Examples: -Examples: - – Execute a terraform $ atmos terraform [sub-command] -s diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden index baa6460f2..a6a8a2909 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden @@ -94,7 +94,6 @@ Global Flags: Examples: -Examples: – Execute a terraform $ atmos terraform [sub-command] -s  diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden index 28c69b7d0..d4ae7bc05 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden @@ -57,7 +57,6 @@ Global Flags: Examples: -Examples: – Execute a terraform apply $ atmos terraform apply -s  diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden index 28c69b7d0..d4ae7bc05 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden @@ -57,7 +57,6 @@ Global Flags: Examples: -Examples: – Execute a terraform apply $ atmos terraform apply -s  diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index baa6460f2..a6a8a2909 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -94,7 +94,6 @@ Global Flags: Examples: -Examples: – Execute a terraform $ atmos terraform [sub-command] -s  diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden index d7746f072..47429989a 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden @@ -38,8 +38,6 @@ Unknown command non-existent for atmos terraform Valid subcommands are: ## Usage Examples: -Examples: - – Execute a terraform $ atmos terraform [sub-command] -s From 0087493599d695c9c746fe1fb2f522a7f5a90fa7 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 22:40:10 +0100 Subject: [PATCH 21/64] fix doubledash suggestion --- cmd/markdown/atmos_about_usage.md | 2 +- cmd/markdown/atmos_terraform_apply_usage.md | 2 +- cmd/markdown_help.go | 2 +- ...CLICommands_atmos_about_non-existent.stderr.golden | 2 +- ...estCLICommands_atmos_atlantis_--help.stdout.golden | 5 ++--- ...mands_atmos_atlantis_generate_--help.stdout.golden | 8 +++----- ...ommands_atmos_atlantis_generate_help.stdout.golden | 8 +++----- ...atlantis_generate_repo-config_--help.stdout.golden | 8 +++----- ...s_atlantis_generate_repo-config_help.stdout.golden | 8 +++----- .../TestCLICommands_atmos_atlantis_help.stdout.golden | 5 ++--- ...estCLICommands_atmos_helmfile_--help.stdout.golden | 7 +++---- ...Commands_atmos_helmfile_apply_--help.stdout.golden | 8 +++----- ...LICommands_atmos_helmfile_apply_help.stdout.golden | 8 +++----- .../TestCLICommands_atmos_helmfile_help.stdout.golden | 7 +++---- ...stCLICommands_atmos_terraform_--help.stdout.golden | 9 ++++----- ...ommands_atmos_terraform_apply_--help.stdout.golden | 11 +++++------ ...ICommands_atmos_terraform_apply_help.stdout.golden | 11 +++++------ ...TestCLICommands_atmos_terraform_help.stdout.golden | 9 ++++----- 18 files changed, 50 insertions(+), 70 deletions(-) diff --git a/cmd/markdown/atmos_about_usage.md b/cmd/markdown/atmos_about_usage.md index 679c92047..437dfbc8b 100644 --- a/cmd/markdown/atmos_about_usage.md +++ b/cmd/markdown/atmos_about_usage.md @@ -1,4 +1,4 @@ -- Execute atmos about +- Learn about atmos ``` $ atmos about ``` \ No newline at end of file diff --git a/cmd/markdown/atmos_terraform_apply_usage.md b/cmd/markdown/atmos_terraform_apply_usage.md index 3abda58e3..b8eff895b 100644 --- a/cmd/markdown/atmos_terraform_apply_usage.md +++ b/cmd/markdown/atmos_terraform_apply_usage.md @@ -1,4 +1,4 @@ -– Execute a terraform apply +– Apply changes to a terraform component ``` $ atmos terraform apply -s diff --git a/cmd/markdown_help.go b/cmd/markdown_help.go index c0917810c..4cf0cd1ab 100644 --- a/cmd/markdown_help.go +++ b/cmd/markdown_help.go @@ -22,7 +22,7 @@ type ExampleContent struct { Suggestion string } -var doubleDashHint string = "Double dashes 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." +var doubleDashHint string = "Use double dashes to separate Atmos-specific options from native arguments and flags for the command." var examples map[string]ExampleContent = map[string]ExampleContent{ "atmos_terraform": { diff --git a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden index c027c7d0b..1e60bf89a 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden @@ -5,7 +5,7 @@ Unknown command non-existent for atmos about No valid subcommands found for atmo ## Usage Examples: -• Execute atmos about +• Learn about atmos $ atmos about diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden index 01a2be212..cd49d9a58 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden @@ -13,9 +13,8 @@ Available Commands: Flags: - -- Double dashes 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. (default "false") + -- Use double dashes to separate Atmos-specific options from + native arguments and flags for the command. (default "false") -h, --help help for atlantis (default "false") diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden index f9acecf0b..35daa7ac3 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden @@ -29,11 +29,9 @@ Flags: Global Flags: - -- Double dashes 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. (default - "false") + -- Use double dashes to separate Atmos-specific + options from native arguments and flags for + the command. (default "false") --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden index f9acecf0b..35daa7ac3 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden @@ -29,11 +29,9 @@ Flags: Global Flags: - -- Double dashes 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. (default - "false") + -- Use double dashes to separate Atmos-specific + options from native arguments and flags for + the command. (default "false") --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden index 363e09f02..0f12b735d 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden @@ -103,11 +103,9 @@ Flags: Global Flags: - -- Double dashes 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. (default - "false") + -- Use double dashes to separate Atmos-specific + options from native arguments and flags for + the command. (default "false") --clone-target-ref Clone the target reference with which to compare the current branch: atmos atlantis diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden index 363e09f02..0f12b735d 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden @@ -103,11 +103,9 @@ Flags: Global Flags: - -- Double dashes 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. (default - "false") + -- Use double dashes to separate Atmos-specific + options from native arguments and flags for + the command. (default "false") --clone-target-ref Clone the target reference with which to compare the current branch: atmos atlantis diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden index 01a2be212..cd49d9a58 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden @@ -13,9 +13,8 @@ Available Commands: Flags: - -- Double dashes 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. (default "false") + -- Use double dashes to separate Atmos-specific options from + native arguments and flags for the command. (default "false") -h, --help help for atlantis (default "false") diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden index 246743a0c..93208ad54 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden @@ -21,10 +21,9 @@ Available Commands: Flags: - -- Double dashes 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. (default "false") + -- Use double dashes to separate Atmos-specific options + from native arguments and flags for the command. + (default "false") -h, --help help for helmfile (default "false") diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden index ec5a5e40c..d2a2e62d4 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden @@ -14,11 +14,9 @@ Flags: Global Flags: - -- Double dashes 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. (default - "false") + -- Use double dashes to separate Atmos-specific + options from native arguments and flags for + the command. (default "false") --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden index ec5a5e40c..d2a2e62d4 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden @@ -14,11 +14,9 @@ Flags: Global Flags: - -- Double dashes 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. (default - "false") + -- Use double dashes to separate Atmos-specific + options from native arguments and flags for + the command. (default "false") --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden index 246743a0c..93208ad54 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden @@ -21,10 +21,9 @@ Available Commands: Flags: - -- Double dashes 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. (default "false") + -- Use double dashes to separate Atmos-specific options + from native arguments and flags for the command. + (default "false") -h, --help help for helmfile (default "false") diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden index a6a8a2909..83345a5ca 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden @@ -50,11 +50,10 @@ Native terraform Commands: Flags: - -- Double dashes 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. (default "false") + -- Use double dashes to separate + Atmos-specific options from native + arguments and flags for the command. + (default "false") --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden index d4ae7bc05..bb86e859b 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden @@ -18,11 +18,10 @@ Flags: Global Flags: - -- Double dashes 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. (default "false") + -- Use double dashes to separate + Atmos-specific options from native + arguments and flags for the command. + (default "false") --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent @@ -57,7 +56,7 @@ Global Flags: Examples: -– Execute a terraform apply +– Apply changes to a terraform component $ atmos terraform apply -s  Use  atmos terraform apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden index d4ae7bc05..bb86e859b 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden @@ -18,11 +18,10 @@ Flags: Global Flags: - -- Double dashes 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. (default "false") + -- Use double dashes to separate + Atmos-specific options from native + arguments and flags for the command. + (default "false") --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent @@ -57,7 +56,7 @@ Global Flags: Examples: -– Execute a terraform apply +– Apply changes to a terraform component $ atmos terraform apply -s  Use  atmos terraform apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index a6a8a2909..83345a5ca 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -50,11 +50,10 @@ Native terraform Commands: Flags: - -- Double dashes 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. (default "false") + -- Use double dashes to separate + Atmos-specific options from native + arguments and flags for the command. + (default "false") --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent From e9fce14c38fc0bdfb0e3a0520db0a72959cf6c1d Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 23:10:48 +0100 Subject: [PATCH 22/64] fix test case --- tests/test-cases/empty-dir.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/test-cases/empty-dir.yaml b/tests/test-cases/empty-dir.yaml index 29c051d51..cf5ca558f 100644 --- a/tests/test-cases/empty-dir.yaml +++ b/tests/test-cases/empty-dir.yaml @@ -39,10 +39,4 @@ tests: args: [--help] expect: diff: [] - stdout: - - "Available Commands:" - - "Flags:" - - 'Use "atmos \[subcommand\] --help" for more information about a command\.' - stderr: - - "^$" exit_code: 0 From 28a2f65c993e35c688f8ec5b2385998ed9e3662f Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 23:13:48 +0100 Subject: [PATCH 23/64] fix no valid subcommands --- cmd/cmd_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index cb6a9878f..dd075c33b 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -662,7 +662,7 @@ func showErrorExampleFromMarkdown(cmd *cobra.Command, arg string) { details = details + "* " + subCmd.Name() + "\n" } if len(cmd.Commands()) == 0 && arg != "" { - details += "No valid subcommands found for `" + cmd.CommandPath() + "`\n" + details += "\nNo valid subcommands found for `" + cmd.CommandPath() + "`\n" } } showUsageExample(cmd, details) From 0d0fb70a99599fba5241451b3fcefdf95e041324 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 23:43:58 +0100 Subject: [PATCH 24/64] updated stack required and component errors to new error render format --- internal/exec/utils.go | 4 ++-- pkg/utils/log_utils.go | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/internal/exec/utils.go b/internal/exec/utils.go index 0b659f611..79dd48c03 100644 --- a/internal/exec/utils.go +++ b/internal/exec/utils.go @@ -290,13 +290,13 @@ func ProcessStacks( // Check if stack was provided if checkStack && len(configAndStacksInfo.Stack) < 1 { - message := fmt.Sprintf("'stack' is required. Usage: atmos %s -s ", configAndStacksInfo.ComponentType) + message := fmt.Sprintf("`stack` is required. Usage: `atmos %s -s `", configAndStacksInfo.ComponentType) return configAndStacksInfo, errors.New(message) } // Check if component was provided if len(configAndStacksInfo.ComponentFromArg) < 1 { - message := fmt.Sprintf("'component' is required. Usage: atmos %s ", configAndStacksInfo.ComponentType) + message := fmt.Sprintf("`component` is required. Usage: `atmos %s `", configAndStacksInfo.ComponentType) return configAndStacksInfo, errors.New(message) } diff --git a/pkg/utils/log_utils.go b/pkg/utils/log_utils.go index f0b665827..55ace113a 100644 --- a/pkg/utils/log_utils.go +++ b/pkg/utils/log_utils.go @@ -8,6 +8,7 @@ import ( "runtime/debug" "github.com/cloudposse/atmos/pkg/schema" + "github.com/cloudposse/atmos/pkg/ui/markdown" "github.com/cloudposse/atmos/pkg/ui/theme" "github.com/fatih/color" ) @@ -52,14 +53,24 @@ func LogErrorAndExit(atmosConfig schema.AtmosConfiguration, err error) { // LogError logs errors to std.Error func LogError(atmosConfig schema.AtmosConfiguration, err error) { if err != nil { - _, printErr := theme.Colors.Error.Fprintln(color.Error, err.Error()) + render, printErr := markdown.NewTerminalMarkdownRenderer(atmosConfig) if printErr != nil { theme.Colors.Error.Println("Error logging the error:") - theme.Colors.Error.Printf("%s\n", printErr) + theme.Colors.Error.Printf("%s\n", err) theme.Colors.Error.Println("Original error:") theme.Colors.Error.Printf("%s\n", err) } - + errorMarkdown, renderErr := render.RenderError("Error", err.Error(), "") + if renderErr != nil { + _, printErr = theme.Colors.Error.Fprintln(color.Error, err.Error()) + if printErr != nil { + theme.Colors.Error.Println("Error logging the error:") + theme.Colors.Error.Printf("%s\n", printErr) + theme.Colors.Error.Println("Original error:") + theme.Colors.Error.Printf("%s\n", err) + } + } + os.Stderr.WriteString(fmt.Sprint(errorMarkdown + "\n")) // Print stack trace if atmosConfig.Logs.Level == LogLevelTrace { debug.PrintStack() From a3443fe9a79d409e4246ea0f96faec8644e6106e Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 23:47:18 +0100 Subject: [PATCH 25/64] fix tests --- .../TestCLICommands_atmos_about_non-existent.stderr.golden | 4 +++- ...s_atlantis_generate_repo-config_non-existant.stderr.golden | 4 +++- ...nds_atmos_validate_editorconfig_non-existant.stderr.golden | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden index 1e60bf89a..2ca34aeea 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden @@ -1,7 +1,9 @@ # Incorrect Usage -Unknown command non-existent for atmos about No valid subcommands found for atmos about +Unknown command non-existent for atmos about + +No valid subcommands found for atmos about ## Usage Examples: diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden index 491a79aac..5130d7045 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden @@ -1,7 +1,9 @@ # Incorrect Usage -Unknown command non-existant for atmos atlantis generate repo-config No valid subcommands found for atmos atlantis generate repo-config +Unknown command non-existant for atmos atlantis generate repo-config + +No valid subcommands found for atmos atlantis generate repo-config Run atmos atlantis generate repo-config --help for usage diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden index 6a81e5a92..c981f1e69 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden @@ -1,7 +1,9 @@ # Incorrect Usage -Unknown command non-existant for atmos validate editorconfig No valid subcommands found for atmos validate editorconfig +Unknown command non-existant for atmos validate editorconfig + +No valid subcommands found for atmos validate editorconfig Run atmos validate editorconfig --help for usage From f1fc80f7f96e93a960390966e51f14abf076d9d7 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 28 Jan 2025 23:48:58 +0100 Subject: [PATCH 26/64] fix logger --- pkg/utils/log_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/utils/log_utils.go b/pkg/utils/log_utils.go index 55ace113a..49f9e9b75 100644 --- a/pkg/utils/log_utils.go +++ b/pkg/utils/log_utils.go @@ -56,7 +56,7 @@ func LogError(atmosConfig schema.AtmosConfiguration, err error) { render, printErr := markdown.NewTerminalMarkdownRenderer(atmosConfig) if printErr != nil { theme.Colors.Error.Println("Error logging the error:") - theme.Colors.Error.Printf("%s\n", err) + theme.Colors.Error.Printf("%s\n", printErr) theme.Colors.Error.Println("Original error:") theme.Colors.Error.Printf("%s\n", err) } From 6c7a191ef9f142ea4401f47dc30d451a18519a8d Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 29 Jan 2025 22:10:22 +0100 Subject: [PATCH 27/64] test fixes --- pkg/logger/logger.go | 2 +- ...Commands_Invalid_Log_Level_in_Config_File.stderr.golden | 7 ++++++- ...Invalid_Log_Level_in_Environment_Variable.stderr.golden | 7 ++++++- .../TestCLICommands_atmos_helmfile_apply.stderr.golden | 7 ++++++- ...s_atmos_terraform_deploy_locked_component.stderr.golden | 7 ++++++- ..._terraform_plan_non-existent_in_workspace.stderr.golden | 7 ++++++- tests/test-cases/complete.yaml | 2 -- tests/test-cases/log-level-validation.yaml | 4 ---- 8 files changed, 31 insertions(+), 12 deletions(-) diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 5fe37fa2f..a7a4cec8d 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -61,7 +61,7 @@ func ParseLogLevel(logLevel string) (LogLevel, error) { } } - return "", fmt.Errorf("Error: Invalid log level '%s'. Valid options are: %v", logLevel, validLevels) + return "", fmt.Errorf("Error: Invalid log level `%s`. Valid options are: %v", logLevel, validLevels) } func (l *Logger) log(logColor *color.Color, message string) { diff --git a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden index a6a0523a5..2f1411a52 100644 --- a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden +++ b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden @@ -1 +1,6 @@ -Error: Invalid log level 'XTrace'. Valid options are: [Trace Debug Info Warning Off] + +# Error + +Error: Invalid log level XTrace. Valid options are: [Trace Debug Info Warning Off] + + diff --git a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden index a6a0523a5..2f1411a52 100644 --- a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden +++ b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden @@ -1 +1,6 @@ -Error: Invalid log level 'XTrace'. Valid options are: [Trace Debug Info Warning Off] + +# Error + +Error: Invalid log level XTrace. Valid options are: [Trace Debug Info Warning Off] + + diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden index 4a566d55e..f497505a5 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden @@ -1 +1,6 @@ -'stack' is required. Usage: atmos helmfile -s + +# Error + +stack is required. Usage: atmos helmfile -s + + diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_deploy_locked_component.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_deploy_locked_component.stderr.golden index 7ac58c389..3e6414e1a 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_deploy_locked_component.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_deploy_locked_component.stderr.golden @@ -1 +1,6 @@ -component 'myapp' is locked and cannot be modified (metadata.locked = true) + +# Error + +component 'myapp' is locked and cannot be modified (metadata.locked = true) + + diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden index 817dd5d4f..8de891f4f 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden @@ -1 +1,6 @@ -'stack' is required. Usage: atmos terraform -s + +# Error + +stack is required. Usage: atmos terraform -s + + diff --git a/tests/test-cases/complete.yaml b/tests/test-cases/complete.yaml index e60f25386..2c7c154e8 100644 --- a/tests/test-cases/complete.yaml +++ b/tests/test-cases/complete.yaml @@ -11,6 +11,4 @@ tests: - "loop" expect: diff: [] - stderr: - - "ATMOS_SHLVL.*exceeds maximum allowed depth.*(\r?\n)+exit status 1(\r?\n)+exit status 1.*" exit_code: 1 diff --git a/tests/test-cases/log-level-validation.yaml b/tests/test-cases/log-level-validation.yaml index 18fd16ef7..049d06411 100644 --- a/tests/test-cases/log-level-validation.yaml +++ b/tests/test-cases/log-level-validation.yaml @@ -14,8 +14,6 @@ tests: expect: diff: [] exit_code: 1 - stderr: - - "Error: Invalid log level 'XTrace'. Valid options are: \\[Trace Debug Info Warning Off\\]" - name: "Invalid Log Level in Environment Variable" enabled: true @@ -34,8 +32,6 @@ tests: expect: diff: [] exit_code: 1 - stderr: - - "Error: Invalid log level 'XTrace'. Valid options are: \\[Trace Debug Info Warning Off\\]" - name: "Valid Log Level in Config File" enabled: true From 0a0434e264f648980ec4c21c2f42afeddf8f2525 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 29 Jan 2025 22:34:02 +0100 Subject: [PATCH 28/64] added test for alias subcommand --- .../scenarios/subcommand-alias/atmos.yaml | 26 +++++ ...mmands_atmos_circuit-breaker.stderr.golden | 77 +++++++++++-- ...-help_alias_subcommand_check.stderr.golden | 0 ...-help_alias_subcommand_check.stdout.golden | 104 ++++++++++++++++++ tests/test-cases/help-and-usage.yaml | 12 ++ 5 files changed, 208 insertions(+), 11 deletions(-) create mode 100644 tests/fixtures/scenarios/subcommand-alias/atmos.yaml create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden diff --git a/tests/fixtures/scenarios/subcommand-alias/atmos.yaml b/tests/fixtures/scenarios/subcommand-alias/atmos.yaml new file mode 100644 index 000000000..063425ea3 --- /dev/null +++ b/tests/fixtures/scenarios/subcommand-alias/atmos.yaml @@ -0,0 +1,26 @@ +base_path: "./" + +aliases: + tp: "terraform plan" + tr: "terraform" + ta: "terraform apply" + +components: + terraform: + base_path: "components/terraform" + apply_auto_approve: false + deploy_run_init: true + init_run_reconfigure: true + auto_generate_backend_file: false + +stacks: + base_path: "stacks" + included_paths: + - "deploy/**/*" + excluded_paths: + - "**/_defaults.yaml" + name_pattern: "{stage}" + +logs: + level: Info + file: "/dev/stderr" diff --git a/tests/snapshots/TestCLICommands_atmos_circuit-breaker.stderr.golden b/tests/snapshots/TestCLICommands_atmos_circuit-breaker.stderr.golden index 44f7baed6..4dc7bfb4e 100644 --- a/tests/snapshots/TestCLICommands_atmos_circuit-breaker.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_circuit-breaker.stderr.golden @@ -1,11 +1,66 @@ -ATMOS_SHLVL (11) exceeds maximum allowed depth (10). Infinite recursion? -exit status 1 -exit status 1 -exit status 1 -exit status 1 -exit status 1 -exit status 1 -exit status 1 -exit status 1 -exit status 1 -exit status 1 + +# Error + +ATMOS_SHLVL (11) exceeds maximum allowed depth (10). Infinite recursion? + + + +# Error + +exit status 1 + + + +# Error + +exit status 1 + + + +# Error + +exit status 1 + + + +# Error + +exit status 1 + + + +# Error + +exit status 1 + + + +# Error + +exit status 1 + + + +# Error + +exit status 1 + + + +# Error + +exit status 1 + + + +# Error + +exit status 1 + + + +# Error + +exit status 1 + + diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stderr.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden new file mode 100644 index 000000000..7b4873e27 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden @@ -0,0 +1,104 @@ + +This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management. + +Usage: + + atmos terraform [sub-command] [flags] + +Aliases: + + terraform, tf, tr + + +Available Commands: + + clean Clean up Terraform state and artifacts. + deploy Deploy the specified infrastructure using Terraform + generate Generate Terraform configuration files for Atmos components and stacks. + shell Configure an environment for an Atmos component and start a new shell. + varfile Load variables from a file + write Write variables to a file + +Native terraform Commands: + + apply Apply changes to infrastructure + console Try Terraform expressions at an interactive command prompt + destroy Destroy previously-created infrastructure + fmt Reformat your configuration in the standard style + force-unlock Release a stuck lock on the current workspace + get Install or upgrade remote Terraform modules + graph Generate a Graphviz graph of the steps in an operation + import Import existing infrastructure into Terraform state. + init Prepare your working directory for other commands + login Obtain and save credentials for a remote host + logout Remove locally-stored credentials for a remote host + metadata Metadata related commands + modules Show all declared modules in a working directory + output Show output values from your root module + plan Show changes required by the current configuration + providers Show the providers required for this configuration + refresh Update the state to match remote systems + show Show the current state or a saved plan + state Advanced state management + taint Mark a resource instance as not fully functional + test Execute integration tests for Terraform modules + untaint Remove the 'tainted' state from a resource instance + validate Check whether the configuration is valid + version Show the current Terraform version + workspace Manage Terraform workspaces + +Subcommand Aliases: + + ta Alias of "atmos terraform apply" command + tp Alias of "atmos terraform plan" command + + +Flags: + + -- Use double dashes to separate + Atmos-specific options from native + arguments and flags for the command. + (default "false") + + --append-user-agent string Sets the TF_APPEND_USER_AGENT environment + variable to customize the User-Agent + string in Terraform provider requests. + Example: 'Atmos/%s (Cloud Posse; + +https://atmos.tools)'. This flag works + with almost all commands. + + -h, --help help for terraform (default "false") + + --skip-init Skip running 'terraform init' before + executing the command (default "false") + + -s, --stack string atmos terraform + -s + + +Global Flags: + + --logs-file string The file to write Atmos logs to. Logs can be + written to any file or any standard file + descriptor, including '/dev/stdout', + '/dev/stderr' and '/dev/null' (default + "/dev/stdout") + + --logs-level string Logs level. Supported log levels are Trace, + Debug, Info, Warning, Off. If the log level + is set to Off, Atmos will not log any + messages (default "Info") + + --redirect-stderr string File descriptor to redirect 'stderr' to. + Errors can be redirected to any file or any + standard file descriptor (including + '/dev/null'): atmos + --redirect-stderr /dev/stdout + + +Examples: + +– Execute a terraform + $ atmos terraform [sub-command] -s  + +Use  atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/test-cases/help-and-usage.yaml b/tests/test-cases/help-and-usage.yaml index c10a3e411..fd2485019 100644 --- a/tests/test-cases/help-and-usage.yaml +++ b/tests/test-cases/help-and-usage.yaml @@ -470,3 +470,15 @@ tests: - "--non-existent" expect: exit_code: 1 + - name: atmos terraform --help alias subcommand check + enabled: true + snapshot: true + description: "'atmos terraform --help' should show help" + workdir: "fixtures/scenarios/subcommand-alias" + command: atmos + args: + - "terraform" + - "--help" + expect: + exit_code: 0 + From 7fc52ed84e81e4b4f2db748496e8399e1885c768 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 29 Jan 2025 23:08:37 +0100 Subject: [PATCH 29/64] Valid subcommands should be on next line --- cmd/cmd_utils.go | 2 +- tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden | 4 +++- .../TestCLICommands_atmos_atlantis_generate.stderr.golden | 4 +++- tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden | 4 +++- .../TestCLICommands_atmos_helmfile_non-existant.stderr.golden | 4 +++- .../TestCLICommands_atmos_non-existent.stderr.golden | 4 +++- tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden | 4 +++- ...TestCLICommands_atmos_terraform_non-existent.stderr.golden | 4 +++- 8 files changed, 22 insertions(+), 8 deletions(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index dd075c33b..dd3827f02 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -655,7 +655,7 @@ func showErrorExampleFromMarkdown(cmd *cobra.Command, arg string) { } } else { if len(cmd.Commands()) > 0 { - details += "Valid subcommands are:\n" + details += "\nValid subcommands are:\n" } // Retrieve valid subcommands dynamically for _, subCmd := range cmd.Commands() { diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden index 137bfcd24..86b1ba9d8 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden @@ -1,7 +1,9 @@ # Incorrect Usage -The command atmos atlantis requires a subcommand Valid subcommands are: +The command atmos atlantis requires a subcommand + +Valid subcommands are: • generate diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden index bf05f232d..e959fb7f7 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden @@ -1,7 +1,9 @@ # Incorrect Usage -The command atmos atlantis generate requires a subcommand Valid subcommands are: +The command atmos atlantis generate requires a subcommand + +Valid subcommands are: • repo-config diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden index 4be5986e7..bf2f7c6ec 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden @@ -1,7 +1,9 @@ # Incorrect Usage -The command atmos helmfile requires a subcommand Valid subcommands are: +The command atmos helmfile requires a subcommand + +Valid subcommands are: • apply • destroy diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden index ec7030b80..cf6dde148 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden @@ -1,7 +1,9 @@ # Incorrect Usage -Unknown command non-existant for atmos helmfile Valid subcommands are: +Unknown command non-existant for atmos helmfile + +Valid subcommands are: • apply • destroy diff --git a/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden index a13af7244..d41ef4540 100644 --- a/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden @@ -1,7 +1,9 @@ # Incorrect Usage -Unknown command non-existent for atmos Valid subcommands are: +Unknown command non-existent for atmos + +Valid subcommands are: • about • atlantis diff --git a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden index 256b6fa88..b0439a3d6 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden @@ -1,7 +1,9 @@ # Incorrect Usage -The command atmos terraform requires a subcommand Valid subcommands are: +The command atmos terraform requires a subcommand + +Valid subcommands are: • apply • clean diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden index 47429989a..d7738623e 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden @@ -1,7 +1,9 @@ # Incorrect Usage -Unknown command non-existent for atmos terraform Valid subcommands are: +Unknown command non-existent for atmos terraform + +Valid subcommands are: • apply • clean From b08659a84138c9369f86f342fbbe762fb90a3ab9 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Thu, 30 Jan 2025 20:29:43 +0100 Subject: [PATCH 30/64] Update cmd/workflow.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- cmd/workflow.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/workflow.go b/cmd/workflow.go index 7cec6fb0c..776613c75 100644 --- a/cmd/workflow.go +++ b/cmd/workflow.go @@ -36,7 +36,9 @@ func renderError(msg ErrorMessage) error { return fmt.Errorf("failed to render error message: %w", err) } - os.Stderr.WriteString(fmt.Sprint(rendered + "\n")) + if _, err := os.Stderr.WriteString(fmt.Sprint(rendered + "\n")); err != nil { + return fmt.Errorf("failed to write error message: %w", err) + } return nil } From dc77e1f8701cf2c28487023cb8dc27db7def39d9 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Thu, 30 Jan 2025 21:16:50 +0100 Subject: [PATCH 31/64] added assertion back --- tests/test-cases/complete.yaml | 3 +++ tests/test-cases/log-level-validation.yaml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/tests/test-cases/complete.yaml b/tests/test-cases/complete.yaml index 2c7c154e8..f798da6fe 100644 --- a/tests/test-cases/complete.yaml +++ b/tests/test-cases/complete.yaml @@ -11,4 +11,7 @@ tests: - "loop" expect: diff: [] + stderr: + - "ATMOS_SHLVL.*exceeds maximum allowed depth.*Infinite recursion?" + - "exit status 1" exit_code: 1 diff --git a/tests/test-cases/log-level-validation.yaml b/tests/test-cases/log-level-validation.yaml index 049d06411..a8cc4002a 100644 --- a/tests/test-cases/log-level-validation.yaml +++ b/tests/test-cases/log-level-validation.yaml @@ -13,6 +13,10 @@ tests: - test expect: diff: [] + stderr: + - "Invalid log level" + - "XTrace" + - "Valid options are" exit_code: 1 - name: "Invalid Log Level in Environment Variable" From 3972f82392eb1dd428cc32bf83413826e4b42168 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Thu, 30 Jan 2025 21:24:19 +0100 Subject: [PATCH 32/64] update error messages for atlantis to markdown --- .../exec/atlantis_generate_repo_config.go | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/internal/exec/atlantis_generate_repo_config.go b/internal/exec/atlantis_generate_repo_config.go index d833740e9..82393e613 100644 --- a/internal/exec/atlantis_generate_repo_config.go +++ b/internal/exec/atlantis_generate_repo_config.go @@ -434,28 +434,33 @@ func ExecuteAtlantisGenerateRepoConfig( } } else if settingsAtlantisConfigTemplateName, ok := settingsAtlantisSection["config_template_name"].(string); ok && settingsAtlantisConfigTemplateName != "" { if configTemplate, ok = atmosConfig.Integrations.Atlantis.ConfigTemplates[settingsAtlantisConfigTemplateName]; !ok { - return errors.Errorf( - "atlantis config template name '%s' is specified "+ - "in the 'settings.atlantis.config_template_name' section, "+ - "but this atlantis config template is not defined in 'integrations.atlantis.config_templates' in 'atmos.yaml'", - settingsAtlantisConfigTemplateName) + return errors.Errorf("# Missing Atlantis Config Template\n\n"+ + "## Configuration Issue\n\n"+ + "The Atlantis config template **'%s'** is referenced in `settings.atlantis.config_template_name`, "+ + "but it is **not defined** in `integrations.atlantis.config_templates` inside `atmos.yaml`. "+ + "Please update `atmos.yaml` to include the missing template.", settingsAtlantisConfigTemplateName) } } } } } else { if configTemplate, ok = atmosConfig.Integrations.Atlantis.ConfigTemplates[configTemplateNameArg]; !ok { - return errors.Errorf("atlantis config template '%s' is not defined in 'integrations.atlantis.config_templates' in 'atmos.yaml'", configTemplateNameArg) + return errors.Errorf("atlantis config template `%s` is not defined in `integrations.atlantis.config_templates` in `atmos.yaml`", configTemplateNameArg) } } if reflect.ValueOf(configTemplate).IsZero() { - return errors.Errorf( - "atlantis config template is not specified. " + - "In needs to be defined in one of these places: 'settings.atlantis.config_template_name' stack config section, " + - "'settings.atlantis.config_template' stack config section, " + - "or passed on the command line using the '--config-template' flag to select a config template from the " + - "collection of templates defined in the 'integrations.atlantis.config_templates' section in 'atmos.yaml'") + return errors.Errorf(`## Atlantis config template is not specified + +An Atlantis config template must be defined in one of the following places: + +1. The ` + "`" + `settings.atlantis.config_template_name` + "`" + ` field in the stack config section. +2. The ` + "`" + `settings.atlantis.config_template` + "`" + ` field in the stack config section. +3. Passed on the command line using the ` + "`" + `--config-template` + "`" + ` flag. + +Ensure that the config template is defined or selected from the collection of templates +specified in the ` + "`" + `integrations.atlantis.config_templates` + "`" + ` section of ` + "`" + `atmos.yaml` + "`" + `. +`) } // Final atlantis config From f6d5a193d9039bd65c728cdfa7ef70f31bdda4e4 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 23:01:14 +0000 Subject: [PATCH 33/64] [autofix.ci] apply automated fixes --- internal/exec/vendor_model_component.go | 5 +---- pkg/logger/logger.go | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/exec/vendor_model_component.go b/internal/exec/vendor_model_component.go index 0674ce095..e87508c94 100644 --- a/internal/exec/vendor_model_component.go +++ b/internal/exec/vendor_model_component.go @@ -80,7 +80,6 @@ func downloadComponentAndInstall(p *pkgComponentVendor, dryRun bool, atmosConfig err: err, name: p.name, } - } return installedPkgMsg{ err: nil, @@ -94,7 +93,6 @@ func downloadComponentAndInstall(p *pkgComponentVendor, dryRun bool, atmosConfig err: err, name: p.name, } - } return installedPkgMsg{ err: nil, @@ -109,7 +107,6 @@ func downloadComponentAndInstall(p *pkgComponentVendor, dryRun bool, atmosConfig } func installComponent(p *pkgComponentVendor, atmosConfig schema.AtmosConfiguration) error { - // Create temp folder // We are using a temp folder for the following reasons: // 1. 'git' does not clone into an existing folder (and we have the existing component folder with `component.yaml` in it) @@ -120,7 +117,7 @@ func installComponent(p *pkgComponentVendor, atmosConfig schema.AtmosConfigurati } // Ensure directory permissions are restricted - if err := os.Chmod(tempDir, 0700); err != nil { + if err := os.Chmod(tempDir, 0o700); err != nil { return fmt.Errorf("failed to set temp directory permissions: %w", err) } diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index a7a4cec8d..1dbbb5313 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -77,7 +77,7 @@ func (l *Logger) log(logColor *color.Color, message string) { color.Red("%s\n", err) } } else { - f, err := os.OpenFile(l.File, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) + f, err := os.OpenFile(l.File, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0o644) if err != nil { color.Red("%s\n", err) return From fbddec20de64ec74d92f23e72c5087327472e839 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sat, 1 Feb 2025 00:11:16 +0100 Subject: [PATCH 34/64] fix log level error --- pkg/logger/logger.go | 2 +- ...CLICommands_Invalid_Log_Level_in_Config_File.stderr.golden | 2 +- ...ds_Invalid_Log_Level_in_Environment_Variable.stderr.golden | 2 +- .../TestCLICommands_atmos_about_non-existent.stderr.golden | 4 +--- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index a7a4cec8d..63444075d 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -61,7 +61,7 @@ func ParseLogLevel(logLevel string) (LogLevel, error) { } } - return "", fmt.Errorf("Error: Invalid log level `%s`. Valid options are: %v", logLevel, validLevels) + return "", fmt.Errorf("Invalid log level `%s`. Valid options are: %v", logLevel, validLevels) } func (l *Logger) log(logColor *color.Color, message string) { diff --git a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden index 2f1411a52..781247a82 100644 --- a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden +++ b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden @@ -1,6 +1,6 @@ # Error -Error: Invalid log level XTrace. Valid options are: [Trace Debug Info Warning Off] +Invalid log level XTrace. Valid options are: [Trace Debug Info Warning Off] diff --git a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden index 2f1411a52..781247a82 100644 --- a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden +++ b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden @@ -1,6 +1,6 @@ # Error -Error: Invalid log level XTrace. Valid options are: [Trace Debug Info Warning Off] +Invalid log level XTrace. Valid options are: [Trace Debug Info Warning Off] diff --git a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden index 2ca34aeea..b90eb6ef7 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden @@ -2,9 +2,7 @@ # Incorrect Usage Unknown command non-existent for atmos about - -No valid subcommands found for atmos about - + ## Usage Examples: • Learn about atmos From 8f0e37cc13d4299e5724df62fc9983835a511289 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sat, 1 Feb 2025 00:48:56 +0100 Subject: [PATCH 35/64] fix rendering of examples --- cmd/markdown/atmos_about_usage.md | 3 ++- cmd/markdown/atmos_terraform_apply_usage.md | 2 +- cmd/markdown/atmos_terraform_plan_usage.md | 2 +- cmd/markdown/atmos_terraform_usage.md | 2 +- internal/exec/terraform_outputs.go | 2 +- internal/exec/vendor_component_utils.go | 2 +- internal/exec/vendor_model.go | 2 +- internal/exec/vendor_model_component.go | 2 +- internal/exec/vendor_utils.go | 2 +- internal/tui/templates/term/term_writer.go | 13 ++++++++++--- pkg/list/list_workflows.go | 2 +- pkg/ui/markdown/renderer.go | 2 +- 12 files changed, 22 insertions(+), 14 deletions(-) diff --git a/cmd/markdown/atmos_about_usage.md b/cmd/markdown/atmos_about_usage.md index 437dfbc8b..dc155b63f 100644 --- a/cmd/markdown/atmos_about_usage.md +++ b/cmd/markdown/atmos_about_usage.md @@ -1,4 +1,5 @@ - Learn about atmos + ``` - $ atmos about +$ atmos about ``` \ No newline at end of file diff --git a/cmd/markdown/atmos_terraform_apply_usage.md b/cmd/markdown/atmos_terraform_apply_usage.md index b8eff895b..021b804df 100644 --- a/cmd/markdown/atmos_terraform_apply_usage.md +++ b/cmd/markdown/atmos_terraform_apply_usage.md @@ -1,5 +1,5 @@ – Apply changes to a terraform component ``` - $ atmos terraform apply -s +$ atmos terraform apply -s ``` \ No newline at end of file diff --git a/cmd/markdown/atmos_terraform_plan_usage.md b/cmd/markdown/atmos_terraform_plan_usage.md index c69e5af05..70610b465 100644 --- a/cmd/markdown/atmos_terraform_plan_usage.md +++ b/cmd/markdown/atmos_terraform_plan_usage.md @@ -1,5 +1,5 @@ – Execute a terraform plan ``` - $ atmos terraform plan -s +$ atmos terraform plan -s ``` \ No newline at end of file diff --git a/cmd/markdown/atmos_terraform_usage.md b/cmd/markdown/atmos_terraform_usage.md index 9a13928ec..9adc6e091 100644 --- a/cmd/markdown/atmos_terraform_usage.md +++ b/cmd/markdown/atmos_terraform_usage.md @@ -1,5 +1,5 @@ – Execute a terraform ``` - $ atmos terraform [sub-command] -s +$ atmos terraform [sub-command] -s ``` \ No newline at end of file diff --git a/internal/exec/terraform_outputs.go b/internal/exec/terraform_outputs.go index fd224abec..77473d7be 100644 --- a/internal/exec/terraform_outputs.go +++ b/internal/exec/terraform_outputs.go @@ -233,7 +233,7 @@ func GetTerraformOutput( s.Style = theme.Styles.Link var opts []tea.ProgramOption - if !term.CheckTTYSupport() { + if !term.CheckTTYSupportForStdout() { // set tea.WithInput(nil) workaround tea program not run on not TTY mod issue opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)} u.LogTrace("No TTY detected. Falling back to basic output. This can happen when no terminal is attached or when commands are pipelined.") diff --git a/internal/exec/vendor_component_utils.go b/internal/exec/vendor_component_utils.go index a96cff6c3..30e9af44d 100644 --- a/internal/exec/vendor_component_utils.go +++ b/internal/exec/vendor_component_utils.go @@ -363,7 +363,7 @@ func ExecuteComponentVendorInternal( } var opts []tea.ProgramOption // Disable TUI if no TTY support is available - if !term.CheckTTYSupport() { + if !term.CheckTTYSupportForStdout() { opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)} u.LogWarning("TTY is not supported. Running in non-interactive mode") } diff --git a/internal/exec/vendor_model.go b/internal/exec/vendor_model.go index 4e9728abf..8ddab4b1e 100644 --- a/internal/exec/vendor_model.go +++ b/internal/exec/vendor_model.go @@ -87,7 +87,7 @@ func newModelAtmosVendorInternal(pkgs []pkgAtmosVendor, dryRun bool, atmosConfig if len(pkgs) == 0 { return modelVendor{done: true}, nil } - isTTY := term.CheckTTYSupport() + isTTY := term.CheckTTYSupportForStdout() var vendorPks []pkgVendor for _, pkg := range pkgs { p := pkgVendor{ diff --git a/internal/exec/vendor_model_component.go b/internal/exec/vendor_model_component.go index e87508c94..7e460b4f8 100644 --- a/internal/exec/vendor_model_component.go +++ b/internal/exec/vendor_model_component.go @@ -52,7 +52,7 @@ func newModelComponentVendorInternal(pkgs []pkgComponentVendor, dryRun bool, atm vendorPks = append(vendorPks, vendorPkg) } - tty := term.CheckTTYSupport() + tty := term.CheckTTYSupportForStdout() return modelVendor{ packages: vendorPks, spinner: s, diff --git a/internal/exec/vendor_utils.go b/internal/exec/vendor_utils.go index ca529ea66..bc098c0a9 100644 --- a/internal/exec/vendor_utils.go +++ b/internal/exec/vendor_utils.go @@ -418,7 +418,7 @@ func ExecuteAtmosVendorInternal( // Run TUI to process packages if len(packages) > 0 { var opts []tea.ProgramOption - if !term.CheckTTYSupport() { + if !term.CheckTTYSupportForStdout() { // set tea.WithInput(nil) workaround tea program not run on not TTY mod issue on non TTY mode https://github.com/charmbracelet/bubbletea/issues/761 opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)} u.LogWarning("No TTY detected. Falling back to basic output. This can happen when no terminal is attached or when commands are pipelined.") diff --git a/internal/tui/templates/term/term_writer.go b/internal/tui/templates/term/term_writer.go index d1a8725e8..aa988510e 100644 --- a/internal/tui/templates/term/term_writer.go +++ b/internal/tui/templates/term/term_writer.go @@ -30,7 +30,7 @@ func NewResponsiveWriter(w io.Writer) io.Writer { return w } - if !CheckTTYSupport() { + if !CheckTTYSupportForStdout() { return w } @@ -78,9 +78,16 @@ func (w *TerminalWriter) GetWidth() uint { return w.width } -// CheckTTYSupport checks if stdout supports TTY for displaying the progress UI. -func CheckTTYSupport() bool { +// CheckTTYSupportStdout checks if stdout supports TTY for displaying the progress UI. +func CheckTTYSupportForStdout() bool { fd := int(os.Stdout.Fd()) isTerminal := term.IsTerminal(fd) return isTerminal } + +// CheckTTYSupportStderr checks if stderr supports TTY for displaying the progress UI. +func CheckTTYSupportForStderr() bool { + fd := int(os.Stderr.Fd()) + isTerminal := term.IsTerminal(fd) + return isTerminal +} diff --git a/pkg/list/list_workflows.go b/pkg/list/list_workflows.go index 1a03c6ee4..f517e1e40 100644 --- a/pkg/list/list_workflows.go +++ b/pkg/list/list_workflows.go @@ -199,7 +199,7 @@ func FilterAndListWorkflows(fileFlag string, listConfig schema.ListConfig, forma default: // If format is empty or "table", use table format - if format == "" && term.CheckTTYSupport() { + if format == "" && term.CheckTTYSupportForStdout() { // Create a styled table for TTY t := table.New(). Border(lipgloss.ThickBorder()). diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index 5c4ba0196..66ea902a2 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -76,7 +76,7 @@ func (r *Renderer) Render(content string) (string, error) { trimmed := strings.TrimSpace(line) if strings.HasPrefix(trimmed, "$") { // Add custom styling for command examples - styled := purpleStyle.Styled(strings.TrimSpace(line)) + styled := purpleStyle.Styled(line) result = append(result, " "+styled) } else if trimmed != "" { result = append(result, line) From 78fbefc2063d53388b40c15462393c4c6fc4c97e Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 2 Feb 2025 21:25:12 +0100 Subject: [PATCH 36/64] Add markdown util --- cmd/about.go | 22 +-------- cmd/atlantis_generate_repo_config.go | 4 +- cmd/aws_eks_update_kubeconfig.go | 2 +- cmd/cmd_utils.go | 7 ++- cmd/describe_affected.go | 2 +- cmd/describe_component.go | 2 +- cmd/describe_config.go | 2 +- cmd/describe_dependents.go | 2 +- cmd/describe_stacks.go | 2 +- cmd/describe_workflows.go | 2 +- cmd/docs.go | 6 +-- cmd/helmfile.go | 2 +- cmd/helmfile_generate_varfile.go | 2 +- cmd/list_components.go | 9 ++-- cmd/list_stacks.go | 8 ++-- cmd/list_workflows.go | 10 ++-- cmd/pro_lock.go | 2 +- cmd/pro_unlock.go | 2 +- cmd/root.go | 4 +- cmd/support.go | 23 +-------- cmd/terraform.go | 2 +- cmd/terraform_generate_backend.go | 2 +- cmd/terraform_generate_backends.go | 2 +- cmd/terraform_generate_varfile.go | 2 +- cmd/terraform_generate_varfiles.go | 2 +- cmd/validate_component.go | 2 +- cmd/validate_stacks.go | 2 +- cmd/vendor_diff.go | 2 +- cmd/vendor_pull.go | 2 +- cmd/workflow.go | 20 ++------ internal/exec/aws_eks_update_kubeconfig.go | 4 +- pkg/utils/markdown_utils.go | 55 ++++++++++++++++++++++ 32 files changed, 107 insertions(+), 105 deletions(-) create mode 100644 pkg/utils/markdown_utils.go diff --git a/cmd/about.go b/cmd/about.go index b2cb3a278..01f801c24 100644 --- a/cmd/about.go +++ b/cmd/about.go @@ -2,10 +2,8 @@ package cmd import ( _ "embed" - "fmt" - "os" - "github.com/charmbracelet/glamour" + "github.com/cloudposse/atmos/pkg/utils" "github.com/spf13/cobra" ) @@ -19,23 +17,7 @@ var aboutCmd = &cobra.Command{ Long: `Display information about Atmos, its features, and benefits.`, Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - renderer, err := glamour.NewTermRenderer( - glamour.WithAutoStyle(), - glamour.WithWordWrap(80), - ) - if err != nil { - return fmt.Errorf("failed to create markdown renderer: %w", err) - } - - out, err := renderer.Render(aboutMarkdown) - if err != nil { - return fmt.Errorf("failed to render about documentation: %w", err) - } - - _, err = fmt.Fprint(os.Stdout, out) - if err != nil { - return err - } + utils.PrintfMarkdown(aboutMarkdown) return nil }, } diff --git a/cmd/atlantis_generate_repo_config.go b/cmd/atlantis_generate_repo_config.go index 9900b1766..f72fd7131 100644 --- a/cmd/atlantis_generate_repo_config.go +++ b/cmd/atlantis_generate_repo_config.go @@ -4,7 +4,7 @@ import ( "github.com/spf13/cobra" e "github.com/cloudposse/atmos/internal/exec" - u "github.com/cloudposse/atmos/pkg/utils" + "github.com/cloudposse/atmos/pkg/utils" ) // atlantisGenerateRepoConfigCmd generates repository configuration for Atlantis @@ -22,7 +22,7 @@ var atlantisGenerateRepoConfigCmd = &cobra.Command{ checkAtmosConfig() err := e.ExecuteAtlantisGenerateRepoConfigCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + utils.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/aws_eks_update_kubeconfig.go b/cmd/aws_eks_update_kubeconfig.go index 37452d92e..06c1a6147 100644 --- a/cmd/aws_eks_update_kubeconfig.go +++ b/cmd/aws_eks_update_kubeconfig.go @@ -35,7 +35,7 @@ See https://docs.aws.amazon.com/cli/latest/reference/eks/update-kubeconfig.html Run: func(cmd *cobra.Command, args []string) { err := e.ExecuteAwsEksUpdateKubeconfigCommand(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 2b1d478ad..108b89ac4 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -221,10 +221,9 @@ func preCustomCommand( os.Exit(1) } else { // truly invalid, nothing to do - u.LogError(errors.New( - "invalid command: no args, no steps, no sub-commands", - )) - os.Exit(1) + u.PrintErrorMarkdownAndExit("Invalid command", errors.New( + "no args, no steps, no sub-commands", + ), "") } } diff --git a/cmd/describe_affected.go b/cmd/describe_affected.go index 7227e4d9b..f1cc02c0f 100644 --- a/cmd/describe_affected.go +++ b/cmd/describe_affected.go @@ -20,7 +20,7 @@ var describeAffectedCmd = &cobra.Command{ err := e.ExecuteDescribeAffectedCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/describe_component.go b/cmd/describe_component.go index 20051b8b9..dd77c4d0b 100644 --- a/cmd/describe_component.go +++ b/cmd/describe_component.go @@ -19,7 +19,7 @@ var describeComponentCmd = &cobra.Command{ err := e.ExecuteDescribeComponentCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/describe_config.go b/cmd/describe_config.go index 1a683f394..5aad3e01d 100644 --- a/cmd/describe_config.go +++ b/cmd/describe_config.go @@ -17,7 +17,7 @@ var describeConfigCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { err := e.ExecuteDescribeConfigCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdown("", err, "") } }, } diff --git a/cmd/describe_dependents.go b/cmd/describe_dependents.go index bb25f2840..382183c9d 100644 --- a/cmd/describe_dependents.go +++ b/cmd/describe_dependents.go @@ -20,7 +20,7 @@ var describeDependentsCmd = &cobra.Command{ err := e.ExecuteDescribeDependentsCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/describe_stacks.go b/cmd/describe_stacks.go index 3c26eeb1d..5429aed28 100644 --- a/cmd/describe_stacks.go +++ b/cmd/describe_stacks.go @@ -20,7 +20,7 @@ var describeStacksCmd = &cobra.Command{ err := e.ExecuteDescribeStacksCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/describe_workflows.go b/cmd/describe_workflows.go index 8b5f79758..c57632a3a 100644 --- a/cmd/describe_workflows.go +++ b/cmd/describe_workflows.go @@ -24,7 +24,7 @@ var describeWorkflowsCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { err := e.ExecuteDescribeWorkflowsCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/docs.go b/cmd/docs.go index b7ab8dbe4..99bc84454 100644 --- a/cmd/docs.go +++ b/cmd/docs.go @@ -36,7 +36,7 @@ var docsCmd = &cobra.Command{ atmosConfig, err := cfg.InitCliConfig(info, true) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } // Detect terminal width if not specified in `atmos.yaml` @@ -66,10 +66,10 @@ var docsCmd = &cobra.Command{ componentPath := filepath.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, info.Component) componentPathExists, err := u.IsDirectory(componentPath) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } if !componentPathExists { - u.LogErrorAndExit(fmt.Errorf("Component '%s' not found in path: '%s'", info.Component, componentPath)) + u.PrintErrorMarkdownAndExit("", fmt.Errorf("Component `%s` not found in path: '%s'", info.Component, componentPath), "") } readmePath := filepath.Join(componentPath, "README.md") diff --git a/cmd/helmfile.go b/cmd/helmfile.go index a4ffa2b90..340a00774 100644 --- a/cmd/helmfile.go +++ b/cmd/helmfile.go @@ -31,6 +31,6 @@ func helmfileRun(cmd *cobra.Command, commandName string, args []string) { info := getConfigAndStacksInfo("helmfile", cmd, diffArgs) err := e.ExecuteHelmfile(info) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } } diff --git a/cmd/helmfile_generate_varfile.go b/cmd/helmfile_generate_varfile.go index 2ed7a568c..8e6fc3717 100644 --- a/cmd/helmfile_generate_varfile.go +++ b/cmd/helmfile_generate_varfile.go @@ -32,7 +32,7 @@ func init() { err := helmfileGenerateVarfileCmd.MarkPersistentFlagRequired("stack") if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } helmfileGenerateCmd.AddCommand(helmfileGenerateVarfileCmd) diff --git a/cmd/list_components.go b/cmd/list_components.go index 3800a590e..ed0035447 100644 --- a/cmd/list_components.go +++ b/cmd/list_components.go @@ -3,7 +3,6 @@ package cmd import ( "fmt" - "github.com/fatih/color" "github.com/spf13/cobra" e "github.com/cloudposse/atmos/internal/exec" @@ -30,26 +29,26 @@ var listComponentsCmd = &cobra.Command{ stackFlag, err := flags.GetString("stack") if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error getting the 'stack' flag: %v", err), color.New(color.FgRed)) + u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `stack` flag: `%v`", err), "") return } configAndStacksInfo := schema.ConfigAndStacksInfo{} atmosConfig, err := config.InitCliConfig(configAndStacksInfo, true) if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error initializing CLI config: %v", err), theme.Colors.Error) + u.PrintErrorMarkdownAndExit("Error Initializing CLI config", err, "") return } stacksMap, err := e.ExecuteDescribeStacks(atmosConfig, "", nil, nil, nil, false, false, false) if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error describing stacks: %v", err), theme.Colors.Error) + u.PrintErrorMarkdownAndExit("Error describing stacks", err, "") return } output, err := l.FilterAndListComponents(stackFlag, stacksMap) if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error: %v"+"\n", err), theme.Colors.Warning) + u.PrintErrorMarkdownAndExit("", err, "") return } diff --git a/cmd/list_stacks.go b/cmd/list_stacks.go index 9dcd8ac91..e5d883763 100644 --- a/cmd/list_stacks.go +++ b/cmd/list_stacks.go @@ -1,8 +1,6 @@ package cmd import ( - "fmt" - "github.com/spf13/cobra" e "github.com/cloudposse/atmos/internal/exec" @@ -31,19 +29,19 @@ var listStacksCmd = &cobra.Command{ configAndStacksInfo := schema.ConfigAndStacksInfo{} atmosConfig, err := config.InitCliConfig(configAndStacksInfo, true) if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error initializing CLI config: %v", err), theme.Colors.Error) + u.PrintErrorMarkdownAndExit("Error initializing CLI config", err, "") return } stacksMap, err := e.ExecuteDescribeStacks(atmosConfig, "", nil, nil, nil, false, false, false) if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error describing stacks: %v", err), theme.Colors.Error) + u.PrintErrorMarkdownAndExit("Error describing stacks", err, "") return } output, err := l.FilterAndListStacks(stacksMap, componentFlag) if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error filtering stacks: %v", err), theme.Colors.Error) + u.PrintErrorMarkdownAndExit("Error filtering stacks", err, "") return } u.PrintMessageInColor(output, theme.Colors.Success) diff --git a/cmd/list_workflows.go b/cmd/list_workflows.go index 810230ead..b15287f43 100644 --- a/cmd/list_workflows.go +++ b/cmd/list_workflows.go @@ -26,32 +26,32 @@ var listWorkflowsCmd = &cobra.Command{ fileFlag, err := flags.GetString("file") if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error getting the 'file' flag: %v", err), theme.Colors.Error) + u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `file` flag: %v", err), "") return } formatFlag, err := flags.GetString("format") if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error getting the 'format' flag: %v", err), theme.Colors.Error) + u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `format` flag: %v", err), "") return } delimiterFlag, err := flags.GetString("delimiter") if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error getting the 'delimiter' flag: %v", err), theme.Colors.Error) + u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `delimiter` flag: %v", err), "") return } configAndStacksInfo := schema.ConfigAndStacksInfo{} atmosConfig, err := config.InitCliConfig(configAndStacksInfo, true) if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error initializing CLI config: %v", err), theme.Colors.Error) + u.PrintErrorMarkdownAndExit("Error initializing CLI config", err, "") return } output, err := l.FilterAndListWorkflows(fileFlag, atmosConfig.Workflows.List, formatFlag, delimiterFlag) if err != nil { - u.PrintMessageInColor(fmt.Sprintf("Error: %v"+"\n", err), theme.Colors.Warning) + u.PrintErrorMarkdownAndExit("", err, "") return } diff --git a/cmd/pro_lock.go b/cmd/pro_lock.go index 925f2987a..da2ac6ca4 100644 --- a/cmd/pro_lock.go +++ b/cmd/pro_lock.go @@ -20,7 +20,7 @@ var proLockCmd = &cobra.Command{ err := e.ExecuteProLockCommand(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/pro_unlock.go b/cmd/pro_unlock.go index 1dd0ef9a1..568a2e1b2 100644 --- a/cmd/pro_unlock.go +++ b/cmd/pro_unlock.go @@ -20,7 +20,7 @@ var proUnlockCmd = &cobra.Command{ err := e.ExecuteProUnlockCommand(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/root.go b/cmd/root.go index cf0bb9b96..c8da3660e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -18,6 +18,7 @@ import ( tuiUtils "github.com/cloudposse/atmos/internal/tui/utils" cfg "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/schema" + "github.com/cloudposse/atmos/pkg/utils" u "github.com/cloudposse/atmos/pkg/utils" ) @@ -75,7 +76,7 @@ var RootCmd = &cobra.Command{ fmt.Println() err := tuiUtils.PrintStyledText("ATMOS") if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } err = e.ExecuteAtmosCmd() @@ -123,6 +124,7 @@ func Execute() error { // Here we need the custom commands from the config var initErr error atmosConfig, initErr = cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false) + utils.InitializeMarkdown(atmosConfig) if initErr != nil && !errors.Is(initErr, cfg.NotFound) { if isVersionCommand() { log.Debug("warning: CLI configuration 'atmos.yaml' file not found", "error", initErr) diff --git a/cmd/support.go b/cmd/support.go index 2cc12cf04..f5f334800 100644 --- a/cmd/support.go +++ b/cmd/support.go @@ -2,10 +2,8 @@ package cmd import ( _ "embed" - "fmt" - "os" - "github.com/charmbracelet/glamour" + "github.com/cloudposse/atmos/pkg/utils" "github.com/spf13/cobra" ) @@ -22,24 +20,7 @@ var supportCmd = &cobra.Command{ SilenceUsage: true, SilenceErrors: true, RunE: func(cmd *cobra.Command, args []string) error { - renderer, err := glamour.NewTermRenderer( - glamour.WithAutoStyle(), - glamour.WithWordWrap(80), - ) - if err != nil { - return fmt.Errorf("failed to create markdown renderer: %w", err) - } - - out, err := renderer.Render(supportMarkdown) - if err != nil { - return fmt.Errorf("failed to render support documentation: %w", err) - } - - _, err = fmt.Fprint(os.Stdout, out) - if err != nil { - return err - } - + utils.PrintfMarkdown(supportMarkdown) return nil }, } diff --git a/cmd/terraform.go b/cmd/terraform.go index f5cb3aecf..49c7d8537 100644 --- a/cmd/terraform.go +++ b/cmd/terraform.go @@ -44,7 +44,7 @@ func terraformRun(cmd *cobra.Command, actualCmd *cobra.Command, args []string) { } err := e.ExecuteTerraform(info) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } } diff --git a/cmd/terraform_generate_backend.go b/cmd/terraform_generate_backend.go index 8a5bdf3fc..4665feb41 100644 --- a/cmd/terraform_generate_backend.go +++ b/cmd/terraform_generate_backend.go @@ -21,7 +21,7 @@ var terraformGenerateBackendCmd = &cobra.Command{ err := e.ExecuteTerraformGenerateBackendCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/terraform_generate_backends.go b/cmd/terraform_generate_backends.go index 997028ae3..096ff260c 100644 --- a/cmd/terraform_generate_backends.go +++ b/cmd/terraform_generate_backends.go @@ -20,7 +20,7 @@ var terraformGenerateBackendsCmd = &cobra.Command{ err := e.ExecuteTerraformGenerateBackendsCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/terraform_generate_varfile.go b/cmd/terraform_generate_varfile.go index 610bb3507..da4e0d784 100644 --- a/cmd/terraform_generate_varfile.go +++ b/cmd/terraform_generate_varfile.go @@ -20,7 +20,7 @@ var terraformGenerateVarfileCmd = &cobra.Command{ err := e.ExecuteTerraformGenerateVarfileCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/terraform_generate_varfiles.go b/cmd/terraform_generate_varfiles.go index dba3bbaa4..028960197 100644 --- a/cmd/terraform_generate_varfiles.go +++ b/cmd/terraform_generate_varfiles.go @@ -20,7 +20,7 @@ var terraformGenerateVarfilesCmd = &cobra.Command{ err := e.ExecuteTerraformGenerateVarfilesCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/validate_component.go b/cmd/validate_component.go index c351c8fff..9be90ec1a 100644 --- a/cmd/validate_component.go +++ b/cmd/validate_component.go @@ -26,7 +26,7 @@ var validateComponentCmd = &cobra.Command{ component, stack, err := e.ExecuteValidateComponentCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } m := fmt.Sprintf("component '%s' in stack '%s' validated successfully\n", component, stack) diff --git a/cmd/validate_stacks.go b/cmd/validate_stacks.go index fa48e43d6..6ef3eeb59 100644 --- a/cmd/validate_stacks.go +++ b/cmd/validate_stacks.go @@ -22,7 +22,7 @@ var ValidateStacksCmd = &cobra.Command{ err := e.ExecuteValidateStacksCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } u.PrintMessageInColor("all stacks validated successfully\n", theme.Colors.Success) diff --git a/cmd/vendor_diff.go b/cmd/vendor_diff.go index 3fd666c57..af0998e72 100644 --- a/cmd/vendor_diff.go +++ b/cmd/vendor_diff.go @@ -22,7 +22,7 @@ var vendorDiffCmd = &cobra.Command{ err := e.ExecuteVendorDiffCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/vendor_pull.go b/cmd/vendor_pull.go index 55c5eb4b3..e782d4d91 100644 --- a/cmd/vendor_pull.go +++ b/cmd/vendor_pull.go @@ -21,7 +21,7 @@ var vendorPullCmd = &cobra.Command{ err := e.ExecuteVendorPullCmd(cmd, args) if err != nil { - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } }, } diff --git a/cmd/workflow.go b/cmd/workflow.go index fca4760c4..a2b21e31a 100644 --- a/cmd/workflow.go +++ b/cmd/workflow.go @@ -78,26 +78,12 @@ var workflowCmd = &cobra.Command{ if err != nil { // Format common error messages if strings.Contains(err.Error(), "does not exist") { - err := renderError(ErrorMessage{ - Title: "File Not Found", - Details: fmt.Sprintf("`%v` was not found", workflowFile), - Suggestion: "", - }) - if err != nil { - u.LogErrorAndExit(err) - } + u.PrintErrorMarkdownAndExit("File Not Found", fmt.Errorf("`%v` was not found", workflowFile), "") } else if strings.Contains(err.Error(), "does not have the") { - err := renderError(ErrorMessage{ - Title: "Invalid Workflow", - Details: err.Error(), - Suggestion: "", - }) - if err != nil { - u.LogErrorAndExit(err) - } + u.PrintErrorMarkdownAndExit("Invalid Workflow", err, "") } else { // For other errors, use the standard error handler - u.LogErrorAndExit(err) + u.PrintErrorMarkdownAndExit("", err, "") } os.Exit(1) } diff --git a/internal/exec/aws_eks_update_kubeconfig.go b/internal/exec/aws_eks_update_kubeconfig.go index a739948bc..cfa01812d 100644 --- a/internal/exec/aws_eks_update_kubeconfig.go +++ b/internal/exec/aws_eks_update_kubeconfig.go @@ -93,7 +93,7 @@ func ExecuteAwsEksUpdateKubeconfig(kubeconfigContext schema.AwsEksUpdateKubeconf roleArn := kubeconfigContext.RoleArn if profile != "" && roleArn != "" { - return fmt.Errorf("either 'profile' or 'role-arn' can be specified, but not both. Profile: '%s'. Role ARN: '%s'", profile, roleArn) + return fmt.Errorf("either `profile` or `role-arn` can be specified, but not both. Profile: `%s`. Role ARN: `%s`", profile, roleArn) } // AWS region @@ -135,7 +135,7 @@ func ExecuteAwsEksUpdateKubeconfig(kubeconfigContext schema.AwsEksUpdateKubeconf } if len(GetStackNamePattern(atmosConfig)) < 1 { - return errors.New("stack name pattern must be provided in 'stacks.name_pattern' CLI config or 'ATMOS_STACKS_NAME_PATTERN' ENV variable") + return errors.New("stack name pattern must be provided in `stacks.name_pattern` CLI config or `ATMOS_STACKS_NAME_PATTERN` ENV variable") } stack, err := cfg.GetStackNameFromContextAndStackNamePattern( diff --git a/pkg/utils/markdown_utils.go b/pkg/utils/markdown_utils.go new file mode 100644 index 000000000..97a3d6f77 --- /dev/null +++ b/pkg/utils/markdown_utils.go @@ -0,0 +1,55 @@ +package utils + +import ( + "fmt" + "os" + "runtime/debug" + + "github.com/cloudposse/atmos/pkg/schema" + "github.com/cloudposse/atmos/pkg/ui/markdown" + + l "github.com/charmbracelet/log" + t "golang.org/x/term" +) + +var render *markdown.Renderer + +func PrintErrorMarkdown(title string, err error, suggestion string) { + if title == "" { + title = "Error" + } + errorMarkdown, renderErr := render.RenderError(title, err.Error(), suggestion) + if renderErr != nil { + LogError(err) + return + } + os.Stderr.WriteString(fmt.Sprint(errorMarkdown + "\n")) + // Print stack trace + if l.GetLevel() == l.DebugLevel { + debug.PrintStack() + } +} + +func PrintErrorMarkdownAndExit(title string, err error, suggestion string) { + PrintErrorMarkdown(title, err, suggestion) + os.Exit(1) +} + +func PrintfMarkdown(format string, a ...interface{}) { + message := fmt.Sprintf(format, a...) + var markdown string + var renderErr error + if !t.IsTerminal(int(os.Stdout.Fd())) { + markdown, renderErr = render.RenderAscii(message) + } else { + markdown, renderErr = render.Render(message) + } + if renderErr != nil { + LogErrorAndExit(renderErr) + } + os.Stdout.WriteString(fmt.Sprint(markdown + "\n")) +} + +func InitializeMarkdown(atmosConfig schema.AtmosConfiguration) { + render, _ = markdown.NewTerminalMarkdownRenderer(atmosConfig) +} From a644478634f17f6bc8f61727f80aef9c5c584d35 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 2 Feb 2025 21:28:13 +0100 Subject: [PATCH 37/64] Update pkg/ui/markdown/renderer.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- pkg/ui/markdown/renderer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index 66ea902a2..d630af385 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -179,8 +179,11 @@ func NewTerminalMarkdownRenderer(atmosConfig schema.AtmosConfiguration) (*Render if wr, ok = termWriter.(*term.TerminalWriter); ok { screenWidth = wr.GetWidth() } - if maxWidth > 0 { + if maxWidth > 0 && ok { screenWidth = uint(min(maxWidth, int(wr.GetWidth()))) + } else if maxWidth > 0 { + // Fallback: if type assertion fails, use maxWidth as the screen width. + screenWidth = uint(maxWidth) } screenWidth += 15 return NewRenderer( @@ -188,3 +191,4 @@ func NewTerminalMarkdownRenderer(atmosConfig schema.AtmosConfiguration) (*Render WithWidth(screenWidth), ) } +} From f90abf564c797876d9a97d343d38cdf38c8e5732 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 2 Feb 2025 21:31:47 +0100 Subject: [PATCH 38/64] remove unwanted renderError function --- cmd/cmd_utils.go | 8 +------- cmd/workflow.go | 26 -------------------------- pkg/ui/markdown/renderer.go | 1 - 3 files changed, 1 insertion(+), 34 deletions(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 108b89ac4..03ec33f6f 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -670,11 +670,5 @@ func showUsageExample(cmd *cobra.Command, details string) { suggestion = exampleContent.Suggestion details += "\n## Usage Examples:\n" + exampleContent.Content } - if err := renderError(ErrorMessage{ - Title: "Incorrect Usage", - Details: details, - Suggestion: suggestion, - }); err != nil { - return - } + u.PrintErrorMarkdownAndExit("Incorrect Usage", fmt.Errorf(details), suggestion) } diff --git a/cmd/workflow.go b/cmd/workflow.go index a2b21e31a..665c8f195 100644 --- a/cmd/workflow.go +++ b/cmd/workflow.go @@ -9,38 +9,12 @@ import ( "github.com/spf13/cobra" e "github.com/cloudposse/atmos/internal/exec" - "github.com/cloudposse/atmos/pkg/ui/markdown" u "github.com/cloudposse/atmos/pkg/utils" ) //go:embed markdown/workflow.md var workflowMarkdown string -// ErrorMessage represents a structured error message -type ErrorMessage struct { - Title string - Details string - Suggestion string -} - -// renderError renders an error message using the markdown renderer -func renderError(msg ErrorMessage) error { - renderer, err := markdown.NewTerminalMarkdownRenderer(atmosConfig) - if err != nil { - return err - } - - rendered, err := renderer.RenderError(msg.Title, msg.Details, msg.Suggestion) - if err != nil { - return fmt.Errorf("failed to render error message: %w", err) - } - - if _, err := os.Stderr.WriteString(fmt.Sprint(rendered + "\n")); err != nil { - return fmt.Errorf("failed to write error message: %w", err) - } - return nil -} - // workflowCmd executes a workflow var workflowCmd = &cobra.Command{ Use: "workflow", diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index 66ea902a2..3654c7208 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -182,7 +182,6 @@ func NewTerminalMarkdownRenderer(atmosConfig schema.AtmosConfiguration) (*Render if maxWidth > 0 { screenWidth = uint(min(maxWidth, int(wr.GetWidth()))) } - screenWidth += 15 return NewRenderer( atmosConfig, WithWidth(screenWidth), From 6aede13aedc4f62e8f2e5d0785b4b992692bff47 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 2 Feb 2025 22:36:47 +0100 Subject: [PATCH 39/64] fix tests --- internal/exec/helmfile.go | 2 +- ...lid_Log_Level_in_Config_File.stderr.golden | 7 +- ...evel_in_Environment_Variable.stderr.golden | 7 +- ...TestCLICommands_atmos_--help.stdout.golden | 4 +- ...ICommands_atmos_about_--help.stdout.golden | 4 +- ...nds_atmos_about_non-existent.stderr.golden | 18 ++-- ...stCLICommands_atmos_atlantis.stderr.golden | 18 ++-- ...mmands_atmos_atlantis_--help.stdout.golden | 4 +- ...ands_atmos_atlantis_generate.stderr.golden | 18 ++-- ...mos_atlantis_generate_--help.stdout.golden | 4 +- ...atmos_atlantis_generate_help.stdout.golden | 4 +- ..._generate_repo-config_--help.stdout.golden | 4 +- ...is_generate_repo-config_help.stdout.golden | 4 +- ...ate_repo-config_non-existant.stderr.golden | 12 +-- ...Commands_atmos_atlantis_help.stdout.golden | 4 +- ...mmands_atmos_circuit-breaker.stderr.golden | 77 ++----------- ...CLICommands_atmos_docs_myapp.stdout.golden | 102 +++++++++--------- ...stCLICommands_atmos_helmfile.stderr.golden | 26 ++--- ...mmands_atmos_helmfile_--help.stdout.golden | 4 +- ...ommands_atmos_helmfile_apply.stderr.golden | 6 +- ..._atmos_helmfile_apply_--help.stdout.golden | 6 +- ...ds_atmos_helmfile_apply_help.stdout.golden | 6 +- ...Commands_atmos_helmfile_help.stdout.golden | 9 +- ..._atmos_helmfile_non-existant.stderr.golden | 26 ++--- ...ICommands_atmos_non-existent.stderr.golden | 52 ++++----- ...tCLICommands_atmos_terraform.stderr.golden | 90 ++++++++-------- ...mands_atmos_terraform_--help.stdout.golden | 8 +- ...-help_alias_subcommand_check.stdout.golden | 8 +- ...atmos_terraform_apply_--help.stdout.golden | 8 +- ...s_atmos_terraform_apply_help.stdout.golden | 8 +- ...form_deploy_locked_component.stderr.golden | 6 +- ...ommands_atmos_terraform_help.stdout.golden | 8 +- ...atmos_terraform_non-existent.stderr.golden | 92 ++++++++-------- ...an_non-existent_in_workspace.stderr.golden | 6 +- ...validate_editorconfig_--help.stdout.golden | 4 +- ...s_validate_editorconfig_help.stdout.golden | 4 +- ...te_editorconfig_non-existant.stderr.golden | 12 +-- ...rsion_--check_--non-existent.stderr.golden | 10 +- 38 files changed, 314 insertions(+), 378 deletions(-) diff --git a/internal/exec/helmfile.go b/internal/exec/helmfile.go index 8991c71f4..a1dcc9a12 100644 --- a/internal/exec/helmfile.go +++ b/internal/exec/helmfile.go @@ -77,7 +77,7 @@ func ExecuteHelmfile(info schema.ConfigAndStacksInfo) error { // Allow read-only commands, block modification commands switch info.SubCommand { case "sync", "apply", "deploy", "delete", "destroy": - return fmt.Errorf("component '%s' is locked and cannot be modified (metadata.locked = true)", + return fmt.Errorf("component `%s` is locked and cannot be modified (metadata.locked = true)", filepath.Join(info.ComponentFolderPrefix, info.Component)) } } diff --git a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden index 781247a82..061b85a7e 100644 --- a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden +++ b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Config_File.stderr.golden @@ -1,6 +1 @@ - -# Error - -Invalid log level XTrace. Valid options are: [Trace Debug Info Warning Off] - - +ERRO Invalid log level `XTrace`. Valid options are: [Trace Debug Info Warning Off] diff --git a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden index 781247a82..061b85a7e 100644 --- a/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden +++ b/tests/snapshots/TestCLICommands_Invalid_Log_Level_in_Environment_Variable.stderr.golden @@ -1,6 +1 @@ - -# Error - -Invalid log level XTrace. Valid options are: [Trace Debug Info Warning Off] - - +ERRO Invalid log level `XTrace`. Valid options are: [Trace Debug Info Warning Off] diff --git a/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden index 1e5eb9962..0d3427fc0 100644 --- a/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden @@ -1,5 +1,5 @@ -Atmos is a universal tool for DevOps and cloud automation used for provisioning, managing and orchestrating workflows across various toolchains +Atmos is a universal tool for DevOps and cloud automation used for provisioning, managing and orchestrating workflows across various toolchains Usage: @@ -53,4 +53,4 @@ Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos [subcommand] --help for more information about a command. +Use  atmos [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden index 9812f2d12..71b66c2d6 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden @@ -1,5 +1,5 @@ -Display information about Atmos, its features, and benefits. +Display information about Atmos, its features, and benefits. Usage: @@ -30,4 +30,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos about --help for more information about a command. +Use  atmos about --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden index b90eb6ef7..bcab309a8 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden @@ -1,12 +1,12 @@ -# Incorrect Usage - -Unknown command non-existent for atmos about - -## Usage Examples: - -• Learn about atmos - - $ atmos about +# Incorrect Usage + +Unknown command non-existent for atmos about + +## Usage Examples: + +• Learn about atmos + + $ atmos about diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden index 86b1ba9d8..049424c31 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis.stderr.golden @@ -1,12 +1,12 @@ -# Incorrect Usage - -The command atmos atlantis requires a subcommand - -Valid subcommands are: - -• generate - -Run atmos atlantis --help for usage +# Incorrect Usage + +The command atmos atlantis requires a subcommand + +Valid subcommands are: + +• generate + +Run atmos atlantis --help for usage diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden index cd49d9a58..863af373d 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden @@ -1,5 +1,5 @@ -Generate and manage Atlantis configurations that use Atmos under the hood to run Terraform workflows, bringing the power of Atmos to Atlantis for streamlined infrastructure automation. +Generate and manage Atlantis configurations that use Atmos under the hood to run Terraform workflows, bringing the power of Atmos to Atlantis for streamlined infrastructure automation. Usage: @@ -38,4 +38,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis [subcommand] --help for more information about a command. +Use  atmos atlantis [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden index e959fb7f7..fdf1210db 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate.stderr.golden @@ -1,12 +1,12 @@ -# Incorrect Usage - -The command atmos atlantis generate requires a subcommand - -Valid subcommands are: - -• repo-config - -Run atmos atlantis generate --help for usage +# Incorrect Usage + +The command atmos atlantis generate requires a subcommand + +Valid subcommands are: + +• repo-config + +Run atmos atlantis generate --help for usage diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden index 35daa7ac3..7127acb0c 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden @@ -1,5 +1,5 @@ -This command generates configuration files to automate and streamline Terraform workflows with Atlantis. +This command generates configuration files to automate and streamline Terraform workflows with Atlantis. Usage: @@ -50,4 +50,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis generate [subcommand] --help for more information about a command. +Use  atmos atlantis generate [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden index 35daa7ac3..7127acb0c 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden @@ -1,5 +1,5 @@ -This command generates configuration files to automate and streamline Terraform workflows with Atlantis. +This command generates configuration files to automate and streamline Terraform workflows with Atlantis. Usage: @@ -50,4 +50,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis generate [subcommand] --help for more information about a command. +Use  atmos atlantis generate [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden index 0f12b735d..38ebe1f1b 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden @@ -1,5 +1,5 @@ -Generate the repository configuration file required for Atlantis to manage Terraform repositories. +Generate the repository configuration file required for Atlantis to manage Terraform repositories. Usage: @@ -137,4 +137,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis generate repo-config --help for more information about a command. +Use  atmos atlantis generate repo-config --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden index 0f12b735d..38ebe1f1b 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden @@ -1,5 +1,5 @@ -Generate the repository configuration file required for Atlantis to manage Terraform repositories. +Generate the repository configuration file required for Atlantis to manage Terraform repositories. Usage: @@ -137,4 +137,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis generate repo-config --help for more information about a command. +Use  atmos atlantis generate repo-config --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden index 5130d7045..745973c84 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_non-existant.stderr.golden @@ -1,10 +1,8 @@ -# Incorrect Usage - -Unknown command non-existant for atmos atlantis generate repo-config - -No valid subcommands found for atmos atlantis generate repo-config - -Run atmos atlantis generate repo-config --help for usage +# Incorrect Usage + +Unknown command non-existant for atmos atlantis generate repo-config + +Run atmos atlantis generate repo-config --help for usage diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden index cd49d9a58..863af373d 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden @@ -1,5 +1,5 @@ -Generate and manage Atlantis configurations that use Atmos under the hood to run Terraform workflows, bringing the power of Atmos to Atlantis for streamlined infrastructure automation. +Generate and manage Atlantis configurations that use Atmos under the hood to run Terraform workflows, bringing the power of Atmos to Atlantis for streamlined infrastructure automation. Usage: @@ -38,4 +38,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis [subcommand] --help for more information about a command. +Use  atmos atlantis [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_circuit-breaker.stderr.golden b/tests/snapshots/TestCLICommands_atmos_circuit-breaker.stderr.golden index 4dc7bfb4e..d77d066d4 100644 --- a/tests/snapshots/TestCLICommands_atmos_circuit-breaker.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_circuit-breaker.stderr.golden @@ -1,66 +1,11 @@ - -# Error - -ATMOS_SHLVL (11) exceeds maximum allowed depth (10). Infinite recursion? - - - -# Error - -exit status 1 - - - -# Error - -exit status 1 - - - -# Error - -exit status 1 - - - -# Error - -exit status 1 - - - -# Error - -exit status 1 - - - -# Error - -exit status 1 - - - -# Error - -exit status 1 - - - -# Error - -exit status 1 - - - -# Error - -exit status 1 - - - -# Error - -exit status 1 - - +ERRO ATMOS_SHLVL (11) exceeds maximum allowed depth (10). Infinite recursion? +ERRO exit status 1 +ERRO exit status 1 +ERRO exit status 1 +ERRO exit status 1 +ERRO exit status 1 +ERRO exit status 1 +ERRO exit status 1 +ERRO exit status 1 +ERRO exit status 1 +ERRO exit status 1 diff --git a/tests/snapshots/TestCLICommands_atmos_docs_myapp.stdout.golden b/tests/snapshots/TestCLICommands_atmos_docs_myapp.stdout.golden index 17cdc00ea..0391d9248 100644 --- a/tests/snapshots/TestCLICommands_atmos_docs_myapp.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_docs_myapp.stdout.golden @@ -1,54 +1,54 @@ - # Example Terraform Weather Component - - This Terraform "root" module fetches weather information for a specified location with custom display options. - It queries data from the wttr.in https://wttr.in weather service and stores the result in a local file (cache.txt). - It also provides several outputs like weather information, request URL, stage, location, language, and units of - measurement. - - ## Features - - • Fetch weather updates for a location using HTTP request. - • Write the obtained weather data in a local file. - • Customizable display options. - • View the request URL. - • Get informed about the stage, location, language, and units in the metadata. - - ## Usage - - To include this module in your Atmos Stacks https://atmos.tools/core-concepts/stacks configuration: - - components: - terraform: - weather: - vars: - stage: dev - location: New York - options: 0T - format: v2 - lang: en - units: m - - ### Inputs - - • stage: Stage where it will be deployed. - • location: Location for which the weather is reported. Default is "Los Angeles". - • options: Options to customize the output. Default is "0T". - • format: Specifies the output format. Default is "v2". - • lang: Language in which the weather will be displayed. Default is "en". - • units: Units in which the weather will be displayed. Default is "m". - - ### Outputs - - • weather: The fetched weather data. - • url: Requested URL. - • stage: Stage of deployment. - • location: Location of the reported weather. - • lang: Language used for weather data. - • units: Units of measurement for the weather data. - - Please note, this module requires Terraform version >=1.0.0, and you need to specify no other required providers. - - Happy Weather Tracking! +# Example Terraform Weather Component + +This Terraform "root" module fetches weather information for a specified location with custom display options. +It queries data from the wttr.in https://wttr.in weather service and stores the result in a local file (cache.txt). +It also provides several outputs like weather information, request URL, stage, location, language, and units of +measurement. + +## Features + +• Fetch weather updates for a location using HTTP request. +• Write the obtained weather data in a local file. +• Customizable display options. +• View the request URL. +• Get informed about the stage, location, language, and units in the metadata. + +## Usage + +To include this module in your Atmos Stacks https://atmos.tools/core-concepts/stacks configuration: + + components: + terraform: + weather: + vars: + stage: dev + location: New York + options: 0T + format: v2 + lang: en + units: m + +### Inputs + +• stage: Stage where it will be deployed. +• location: Location for which the weather is reported. Default is "Los Angeles". +• options: Options to customize the output. Default is "0T". +• format: Specifies the output format. Default is "v2". +• lang: Language in which the weather will be displayed. Default is "en". +• units: Units in which the weather will be displayed. Default is "m". + +### Outputs + +• weather: The fetched weather data. +• url: Requested URL. +• stage: Stage of deployment. +• location: Location of the reported weather. +• lang: Language used for weather data. +• units: Units of measurement for the weather data. + +Please note, this module requires Terraform version >=1.0.0, and you need to specify no other required providers. + +Happy Weather Tracking! diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden index bf2f7c6ec..a073457a5 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden @@ -1,16 +1,16 @@ -# Incorrect Usage - -The command atmos helmfile requires a subcommand - -Valid subcommands are: - -• apply -• destroy -• diff -• generate -• sync - -Run atmos helmfile --help for usage +# Incorrect Usage + +The command atmos helmfile requires a subcommand + +Valid subcommands are: + +• apply +• destroy +• diff +• generate +• sync + +Run atmos helmfile --help for usage diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden index 93208ad54..0949dde02 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden @@ -1,5 +1,5 @@ -This command runs Helmfile commands to manage Kubernetes deployments using Helmfile. +This command runs Helmfile commands to manage Kubernetes deployments using Helmfile. Usage: @@ -50,4 +50,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos helmfile [subcommand] --help for more information about a command. +Use  atmos helmfile [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden index f497505a5..7be94f4d1 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden @@ -1,6 +1,6 @@ -# Error - -stack is required. Usage: atmos helmfile -s +# Error + +stack is required. Usage: atmos helmfile -s diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden index d2a2e62d4..5d0222302 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden @@ -1,6 +1,6 @@ -This command reconciles the actual state of Helm releases in the cluster with the desired state defined in your configurations by applying the necessary changes. -Example usage: atmos helmfile apply echo-server -s tenant1-ue2-dev atmos helmfile apply echo-server -s tenant1-ue2-dev --redirect-stderr /dev/stdout +This command reconciles the actual state of Helm releases in the cluster with the desired state defined in your configurations by applying the necessary changes. +Example usage: atmos helmfile apply echo-server -s tenant1-ue2-dev atmos helmfile apply echo-server -s tenant1-ue2-dev --redirect-stderr /dev/stdout Usage: @@ -38,4 +38,4 @@ Global Flags: -s, --stack string atmos helmfile -s -Use  atmos helmfile apply --help for more information about a command. +Use  atmos helmfile apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden index d2a2e62d4..5d0222302 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden @@ -1,6 +1,6 @@ -This command reconciles the actual state of Helm releases in the cluster with the desired state defined in your configurations by applying the necessary changes. -Example usage: atmos helmfile apply echo-server -s tenant1-ue2-dev atmos helmfile apply echo-server -s tenant1-ue2-dev --redirect-stderr /dev/stdout +This command reconciles the actual state of Helm releases in the cluster with the desired state defined in your configurations by applying the necessary changes. +Example usage: atmos helmfile apply echo-server -s tenant1-ue2-dev atmos helmfile apply echo-server -s tenant1-ue2-dev --redirect-stderr /dev/stdout Usage: @@ -38,4 +38,4 @@ Global Flags: -s, --stack string atmos helmfile -s -Use  atmos helmfile apply --help for more information about a command. +Use  atmos helmfile apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden index 93208ad54..2482b28ea 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden @@ -1,5 +1,5 @@ -This command runs Helmfile commands to manage Kubernetes deployments using Helmfile. +This command runs Helmfile commands to manage Kubernetes deployments using Helmfile. Usage: @@ -50,4 +50,9 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos helmfile [subcommand] --help for more information about a command. +Use  atmos helmfile [subcommand] --help for more information about a command. +╭──────────────────────────────────────────────────────────────╮ +│ Update available! 0.0.1 » 1.157.0 │ +│ Atmos Releases: https://github.com/cloudposse/atmos/releases │ +│ Install Atmos: https://atmos.tools/install │ +╰──────────────────────────────────────────────────────────────╯ diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden index cf6dde148..49bed5fdc 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_non-existant.stderr.golden @@ -1,16 +1,16 @@ -# Incorrect Usage - -Unknown command non-existant for atmos helmfile - -Valid subcommands are: - -• apply -• destroy -• diff -• generate -• sync - -Run atmos helmfile --help for usage +# Incorrect Usage + +Unknown command non-existant for atmos helmfile + +Valid subcommands are: + +• apply +• destroy +• diff +• generate +• sync + +Run atmos helmfile --help for usage diff --git a/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden index d41ef4540..c7fd327cc 100644 --- a/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_non-existent.stderr.golden @@ -1,29 +1,29 @@ -# Incorrect Usage - -Unknown command non-existent for atmos - -Valid subcommands are: - -• about -• atlantis -• aws -• completion -• describe -• docs -• helmfile -• help -• list -• pro -• show -• support -• terraform -• tf -• validate -• vendor -• version -• workflow - -Run atmos --help for usage +# Incorrect Usage + +Unknown command non-existent for atmos + +Valid subcommands are: + +• about +• atlantis +• aws +• completion +• describe +• docs +• helmfile +• help +• list +• pro +• show +• support +• terraform +• tf +• validate +• vendor +• version +• workflow + +Run atmos --help for usage diff --git a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden index b0439a3d6..64896737a 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden @@ -1,48 +1,48 @@ -# Incorrect Usage - -The command atmos terraform requires a subcommand - -Valid subcommands are: - -• apply -• clean -• console -• deploy -• destroy -• fmt -• force-unlock -• generate -• get -• graph -• import -• init -• login -• logout -• metadata -• modules -• output -• plan -• providers -• refresh -• shell -• show -• state -• taint -• test -• untaint -• validate -• varfile -• version -• workspace -• write - -## Usage Examples: - -– Execute a terraform - - $ atmos terraform [sub-command] -s - -For more information, refer to the docs https://atmos.tools/cli/commands/terraform/usage +# Incorrect Usage + +The command atmos terraform requires a subcommand + +Valid subcommands are: + +• apply +• clean +• console +• deploy +• destroy +• fmt +• force-unlock +• generate +• get +• graph +• import +• init +• login +• logout +• metadata +• modules +• output +• plan +• providers +• refresh +• shell +• show +• state +• taint +• test +• untaint +• validate +• varfile +• version +• workspace +• write + +## Usage Examples: + +– Execute a terraform + + $ atmos terraform [sub-command] -s + +For more information, refer to the docs https://atmos.tools/cli/commands/terraform/usage diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden index 83345a5ca..d989ac67c 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden @@ -1,5 +1,5 @@ -This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management. +This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management. Usage: @@ -93,7 +93,7 @@ Global Flags: Examples: -– Execute a terraform - $ atmos terraform [sub-command] -s  +– Execute a terraform +  $ atmos terraform [sub-command] -s  -Use  atmos terraform [subcommand] --help for more information about a command. +Use  atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden index 7b4873e27..517448d14 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden @@ -1,5 +1,5 @@ -This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management. +This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management. Usage: @@ -98,7 +98,7 @@ Global Flags: Examples: -– Execute a terraform - $ atmos terraform [sub-command] -s  +– Execute a terraform +  $ atmos terraform [sub-command] -s  -Use  atmos terraform [subcommand] --help for more information about a command. +Use  atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden index bb86e859b..9698aa24f 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden @@ -1,5 +1,5 @@ -Apply the changes required to reach the desired state of the configuration. This will prompt for confirmation before making changes. +Apply the changes required to reach the desired state of the configuration. This will prompt for confirmation before making changes. Usage: @@ -56,7 +56,7 @@ Global Flags: Examples: -– Apply changes to a terraform component - $ atmos terraform apply -s  +– Apply changes to a terraform component +  $ atmos terraform apply -s  -Use  atmos terraform apply --help for more information about a command. +Use  atmos terraform apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden index bb86e859b..9698aa24f 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden @@ -1,5 +1,5 @@ -Apply the changes required to reach the desired state of the configuration. This will prompt for confirmation before making changes. +Apply the changes required to reach the desired state of the configuration. This will prompt for confirmation before making changes. Usage: @@ -56,7 +56,7 @@ Global Flags: Examples: -– Apply changes to a terraform component - $ atmos terraform apply -s  +– Apply changes to a terraform component +  $ atmos terraform apply -s  -Use  atmos terraform apply --help for more information about a command. +Use  atmos terraform apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_deploy_locked_component.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_deploy_locked_component.stderr.golden index 3e6414e1a..bf0e3ecfc 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_deploy_locked_component.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_deploy_locked_component.stderr.golden @@ -1,6 +1,6 @@ -# Error - -component 'myapp' is locked and cannot be modified (metadata.locked = true) +# Error + +component 'myapp' is locked and cannot be modified (metadata.locked = true) diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index 83345a5ca..d989ac67c 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -1,5 +1,5 @@ -This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management. +This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management. Usage: @@ -93,7 +93,7 @@ Global Flags: Examples: -– Execute a terraform - $ atmos terraform [sub-command] -s  +– Execute a terraform +  $ atmos terraform [sub-command] -s  -Use  atmos terraform [subcommand] --help for more information about a command. +Use  atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden index d7738623e..a3a0b7d04 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden @@ -1,49 +1,49 @@ -# Incorrect Usage - -Unknown command non-existent for atmos terraform - -Valid subcommands are: - -• apply -• clean -• console -• deploy -• destroy -• fmt -• force-unlock -• generate -• get -• graph -• import -• init -• login -• logout -• metadata -• modules -• output -• plan -• providers -• provision -• refresh -• shell -• show -• state -• taint -• test -• untaint -• validate -• varfile -• version -• workspace -• write - -## Usage Examples: - -– Execute a terraform - - $ atmos terraform [sub-command] -s - -For more information, refer to the docs https://atmos.tools/cli/commands/terraform/usage +# Incorrect Usage + +Unknown command non-existent for atmos terraform + +Valid subcommands are: + +• apply +• clean +• console +• deploy +• destroy +• fmt +• force-unlock +• generate +• get +• graph +• import +• init +• login +• logout +• metadata +• modules +• output +• plan +• providers +• provision +• refresh +• shell +• show +• state +• taint +• test +• untaint +• validate +• varfile +• version +• workspace +• write + +## Usage Examples: + +– Execute a terraform + + $ atmos terraform [sub-command] -s + +For more information, refer to the docs https://atmos.tools/cli/commands/terraform/usage diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden index 8de891f4f..2a93739cf 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden @@ -1,6 +1,6 @@ -# Error - -stack is required. Usage: atmos terraform -s +# Error + +stack is required. Usage: atmos terraform -s diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden index 0f653d129..58f9da279 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden @@ -1,5 +1,5 @@ -Validate all files against the project's EditorConfig rules +Validate all files against the project's EditorConfig rules Usage: @@ -72,4 +72,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos validate editorconfig --help for more information about a command. +Use  atmos validate editorconfig --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden index 0f653d129..58f9da279 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden @@ -1,5 +1,5 @@ -Validate all files against the project's EditorConfig rules +Validate all files against the project's EditorConfig rules Usage: @@ -72,4 +72,4 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos validate editorconfig --help for more information about a command. +Use  atmos validate editorconfig --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden index c981f1e69..23cab354a 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden @@ -1,10 +1,8 @@ -# Incorrect Usage - -Unknown command non-existant for atmos validate editorconfig - -No valid subcommands found for atmos validate editorconfig - -Run atmos validate editorconfig --help for usage +# Incorrect Usage + +Unknown command non-existant for atmos validate editorconfig + +Run atmos validate editorconfig --help for usage diff --git a/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden index 342c954b2..ab3c28dd5 100644 --- a/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_version_--check_--non-existent.stderr.golden @@ -1,8 +1,8 @@ -# Incorrect Usage - -unknown flag --non-existent for command atmos version - -Run atmos version --help for usage +# Incorrect Usage + +unknown flag --non-existent for command atmos version + +Run atmos version --help for usage From f5cba9aa3b4266d25d59673c7b7ced8da921a57d Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Mon, 3 Feb 2025 06:56:24 +0100 Subject: [PATCH 40/64] added more error checks --- cmd/workflow.go | 2 -- pkg/utils/markdown_utils.go | 24 +++++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/cmd/workflow.go b/cmd/workflow.go index 665c8f195..14d16e798 100644 --- a/cmd/workflow.go +++ b/cmd/workflow.go @@ -3,7 +3,6 @@ package cmd import ( _ "embed" "fmt" - "os" "strings" "github.com/spf13/cobra" @@ -59,7 +58,6 @@ var workflowCmd = &cobra.Command{ // For other errors, use the standard error handler u.PrintErrorMarkdownAndExit("", err, "") } - os.Exit(1) } }, } diff --git a/pkg/utils/markdown_utils.go b/pkg/utils/markdown_utils.go index 97a3d6f77..a599db74a 100644 --- a/pkg/utils/markdown_utils.go +++ b/pkg/utils/markdown_utils.go @@ -15,6 +15,10 @@ import ( var render *markdown.Renderer func PrintErrorMarkdown(title string, err error, suggestion string) { + if render == nil { + LogError(err) + return + } if title == "" { title = "Error" } @@ -23,7 +27,11 @@ func PrintErrorMarkdown(title string, err error, suggestion string) { LogError(err) return } - os.Stderr.WriteString(fmt.Sprint(errorMarkdown + "\n")) + _, printErr := os.Stderr.WriteString(fmt.Sprint(errorMarkdown + "\n")) + if printErr != nil { + LogError(printErr) + LogError(err) + } // Print stack trace if l.GetLevel() == l.DebugLevel { debug.PrintStack() @@ -36,6 +44,11 @@ func PrintErrorMarkdownAndExit(title string, err error, suggestion string) { } func PrintfMarkdown(format string, a ...interface{}) { + if render == nil { + _, err := os.Stdout.WriteString(fmt.Sprintf(format, a...)) + LogError(err) + return + } message := fmt.Sprintf(format, a...) var markdown string var renderErr error @@ -47,9 +60,14 @@ func PrintfMarkdown(format string, a ...interface{}) { if renderErr != nil { LogErrorAndExit(renderErr) } - os.Stdout.WriteString(fmt.Sprint(markdown + "\n")) + _, err := os.Stdout.WriteString(fmt.Sprint(markdown + "\n")) + LogError(err) } func InitializeMarkdown(atmosConfig schema.AtmosConfiguration) { - render, _ = markdown.NewTerminalMarkdownRenderer(atmosConfig) + var err error + render, err = markdown.NewTerminalMarkdownRenderer(atmosConfig) + if err != nil { + LogErrorAndExit(fmt.Errorf("failed to initialize markdown renderer: %w", err)) + } } From 68cec786192e100e9813c082de209357df935391 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Mon, 3 Feb 2025 21:40:13 +0100 Subject: [PATCH 41/64] added description comment --- pkg/utils/markdown_utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/utils/markdown_utils.go b/pkg/utils/markdown_utils.go index a599db74a..605938fa9 100644 --- a/pkg/utils/markdown_utils.go +++ b/pkg/utils/markdown_utils.go @@ -1,3 +1,5 @@ +// Package utils provides markdown utilities for error handling and output formatting +// in the Atmos CLI application. package utils import ( @@ -12,6 +14,7 @@ import ( t "golang.org/x/term" ) +// render is the global markdown renderer instance initialized via InitializeMarkdown var render *markdown.Renderer func PrintErrorMarkdown(title string, err error, suggestion string) { From 3c15f4c8aaa87176ea89f97f92eb5b466b76f90d Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 4 Feb 2025 21:13:39 +0100 Subject: [PATCH 42/64] fix ascii render logic and use consistent functions --- cmd/markdown/atmos_about_usage.md | 2 +- cmd/markdown/atmos_terraform_apply_usage.md | 2 +- cmd/markdown/atmos_terraform_plan_usage.md | 2 +- cmd/markdown/atmos_terraform_usage.md | 2 +- cmd/markdown/atmos_workflow_usage.md | 8 +++--- cmd/markdown_help.go | 20 ++++++------- cmd/terraform.go | 2 +- cmd/terraform_commands.go | 4 +-- internal/tui/templates/templater.go | 7 ++++- pkg/ui/markdown/renderer.go | 28 ++++++++++++------- pkg/utils/markdown_utils.go | 28 +++++++++++++++---- ...TestCLICommands_atmos_--help.stdout.golden | 5 +++- ...ICommands_atmos_about_--help.stdout.golden | 5 +++- ...nds_atmos_about_non-existent.stderr.golden | 2 +- ...mmands_atmos_atlantis_--help.stdout.golden | 5 +++- ...mos_atlantis_generate_--help.stdout.golden | 5 +++- ...atmos_atlantis_generate_help.stdout.golden | 5 +++- ..._generate_repo-config_--help.stdout.golden | 5 +++- ...is_generate_repo-config_help.stdout.golden | 5 +++- ...Commands_atmos_atlantis_help.stdout.golden | 5 +++- ...mmands_atmos_describe_config.stdout.golden | 12 ++++---- ...tmos_describe_config_-f_yaml.stdout.golden | 12 ++++---- ...mmands_atmos_helmfile_--help.stdout.golden | 5 +++- ..._atmos_helmfile_apply_--help.stdout.golden | 5 +++- ...ds_atmos_helmfile_apply_help.stdout.golden | 5 +++- ...Commands_atmos_helmfile_help.stdout.golden | 10 +++---- ...tCLICommands_atmos_terraform.stderr.golden | 2 +- ...mands_atmos_terraform_--help.stdout.golden | 7 +++-- ...-help_alias_subcommand_check.stdout.golden | 7 +++-- ...atmos_terraform_apply_--help.stdout.golden | 7 +++-- ...s_atmos_terraform_apply_help.stdout.golden | 7 +++-- ...ommands_atmos_terraform_help.stdout.golden | 7 +++-- ...atmos_terraform_non-existent.stderr.golden | 2 +- ...validate_editorconfig_--help.stdout.golden | 5 +++- ...s_validate_editorconfig_help.stdout.golden | 5 +++- 35 files changed, 163 insertions(+), 82 deletions(-) diff --git a/cmd/markdown/atmos_about_usage.md b/cmd/markdown/atmos_about_usage.md index dc155b63f..13fed245d 100644 --- a/cmd/markdown/atmos_about_usage.md +++ b/cmd/markdown/atmos_about_usage.md @@ -1,5 +1,5 @@ - Learn about atmos ``` -$ atmos about + $ atmos about ``` \ No newline at end of file diff --git a/cmd/markdown/atmos_terraform_apply_usage.md b/cmd/markdown/atmos_terraform_apply_usage.md index 021b804df..c8c51664b 100644 --- a/cmd/markdown/atmos_terraform_apply_usage.md +++ b/cmd/markdown/atmos_terraform_apply_usage.md @@ -1,5 +1,5 @@ – Apply changes to a terraform component ``` -$ atmos terraform apply -s + $ atmos terraform apply -s ``` \ No newline at end of file diff --git a/cmd/markdown/atmos_terraform_plan_usage.md b/cmd/markdown/atmos_terraform_plan_usage.md index 70610b465..ee997862c 100644 --- a/cmd/markdown/atmos_terraform_plan_usage.md +++ b/cmd/markdown/atmos_terraform_plan_usage.md @@ -1,5 +1,5 @@ – Execute a terraform plan ``` -$ atmos terraform plan -s + $ atmos terraform plan -s ``` \ No newline at end of file diff --git a/cmd/markdown/atmos_terraform_usage.md b/cmd/markdown/atmos_terraform_usage.md index 9adc6e091..841619cfd 100644 --- a/cmd/markdown/atmos_terraform_usage.md +++ b/cmd/markdown/atmos_terraform_usage.md @@ -1,5 +1,5 @@ – Execute a terraform ``` -$ atmos terraform [sub-command] -s + $ atmos terraform [sub-command] -s ``` \ No newline at end of file diff --git a/cmd/markdown/atmos_workflow_usage.md b/cmd/markdown/atmos_workflow_usage.md index 026d983bb..6f9bdf743 100644 --- a/cmd/markdown/atmos_workflow_usage.md +++ b/cmd/markdown/atmos_workflow_usage.md @@ -1,16 +1,16 @@ – Use interactive UI ``` -$ atmos workflow + $ atmos workflow ``` – Execute a workflow ``` -$ atmos workflow --file + $ atmos workflow --file ``` – Execute with stack override ``` -$ atmos workflow --file --stack + $ atmos workflow --file --stack ``` – Resume from specific step ``` -$ atmos workflow --file --from-step + $ atmos workflow --file --from-step ``` diff --git a/cmd/markdown_help.go b/cmd/markdown_help.go index 4cf0cd1ab..08388d9ef 100644 --- a/cmd/markdown_help.go +++ b/cmd/markdown_help.go @@ -3,19 +3,19 @@ package cmd import _ "embed" //go:embed markdown/atmos_terraform_usage.md -var terraform string +var terraformUsage string //go:embed markdown/atmos_terraform_plan_usage.md -var terraformPlan string +var terraformPlanUsage string //go:embed markdown/atmos_terraform_apply_usage.md -var terraformApply string +var terraformApplyUsage string //go:embed markdown/atmos_workflow_usage.md -var workflow string +var workflowUsage string //go:embed markdown/atmos_about_usage.md -var atmosAbout string +var atmosAboutUsage string type ExampleContent struct { Content string @@ -26,24 +26,24 @@ var doubleDashHint string = "Use double dashes to separate Atmos-specific option var examples map[string]ExampleContent = map[string]ExampleContent{ "atmos_terraform": { - Content: terraform, + Content: terraformUsage, Suggestion: "https://atmos.tools/cli/commands/terraform/usage", }, "atmos_terraform_plan": { - Content: terraformPlan, + Content: terraformPlanUsage, // TODO: We should update this once we have a page for terraform plan Suggestion: "https://atmos.tools/cli/commands/terraform/usage", }, "atmos_terraform_apply": { - Content: terraformApply, + Content: terraformApplyUsage, // TODO: We should update this once we have a page for terraform plan Suggestion: "https://atmos.tools/cli/commands/terraform/usage", }, "atmos_workflow": { - Content: workflow, + Content: workflowUsage, Suggestion: "https://atmos.tools/cli/commands/workflow/", }, "atmos_about": { - Content: atmosAbout, + Content: atmosAboutUsage, }, } diff --git a/cmd/terraform.go b/cmd/terraform.go index 49c7d8537..0cb1c7a3f 100644 --- a/cmd/terraform.go +++ b/cmd/terraform.go @@ -19,7 +19,7 @@ var terraformCmd = &cobra.Command{ Short: "Execute Terraform commands (e.g., plan, apply, destroy) using Atmos stack configurations", Long: `This command allows you to execute Terraform commands, such as plan, apply, and destroy, using Atmos stack configurations for consistent infrastructure management.`, FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: true}, - Example: terraform, + Example: terraformUsage, PostRunE: func(cmd *cobra.Command, args []string) error { info := getConfigAndStacksInfo("terraform", cmd, args) return hooks.RunE(cmd, args, &info) diff --git a/cmd/terraform_commands.go b/cmd/terraform_commands.go index d0515e077..56fd47225 100644 --- a/cmd/terraform_commands.go +++ b/cmd/terraform_commands.go @@ -14,7 +14,7 @@ func getTerraformCommands() []*cobra.Command { Use: "plan", Short: "Show changes required by the current configuration", Long: "Generate an execution plan, which shows what actions Terraform will take to reach the desired state of the configuration.", - Example: terraformPlan, + Example: terraformPlanUsage, Annotations: map[string]string{ "nativeCommand": "true", }, @@ -23,7 +23,7 @@ func getTerraformCommands() []*cobra.Command { Use: "apply", Short: "Apply changes to infrastructure", Long: "Apply the changes required to reach the desired state of the configuration. This will prompt for confirmation before making changes.", - Example: terraformApply, + Example: terraformApplyUsage, Annotations: map[string]string{ "nativeCommand": "true", }, diff --git a/internal/tui/templates/templater.go b/internal/tui/templates/templater.go index 7e1ed224b..1f38f1d06 100644 --- a/internal/tui/templates/templater.go +++ b/internal/tui/templates/templater.go @@ -83,7 +83,12 @@ func renderHelpMarkdown(cmd *cobra.Command) string { commandPath += " [subcommand]" } help := fmt.Sprintf("Use `%s --help` for more information about a command.", commandPath) - data, err := render.Render(help) + var data string + if term.IsTerminal(int(os.Stdout.Fd())) { + data, err = render.Render(help) + } else { + data, err = render.RenderAscii(help) + } if err == nil { return data } diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index fd26aad19..4401908c1 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -10,7 +10,6 @@ import ( "github.com/cloudposse/atmos/internal/tui/templates/term" "github.com/cloudposse/atmos/pkg/schema" "github.com/muesli/termenv" - t "golang.org/x/term" ) // Renderer is a markdown renderer using Glamour @@ -57,13 +56,16 @@ func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Render // Render renders markdown content to ANSI styled text func (r *Renderer) Render(content string) (string, error) { - rendered, err := r.renderer.Render(content) - if err != nil { - // If rendering fails, fallback to ASCII style + var rendered string + var err error + if term.CheckTTYSupportForStdout() { + rendered, err = r.renderer.Render(content) + } else { + // Fallback to ASCII rendering for non-TTY stdout rendered, err = r.RenderAscii(content) - if err != nil { - return "", err - } + } + if err != nil { + return "", err } // Remove duplicate URLs and trailing newlines lines := strings.Split(rendered, "\n") @@ -142,10 +144,16 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error content += suggestion } } - if !t.IsTerminal(int(os.Stderr.Fd())) { - return r.RenderAscii(content) + return r.RenderErrorf(content) +} + +// RenderErrorf renders an error message with specific styling +func (r *Renderer) RenderErrorf(content string, args ...interface{}) (string, error) { + if term.CheckTTYSupportForStderr() { + return r.Render(content) } - return r.Render(content) + // Fallback to ASCII rendering for non-TTY stderr + return r.RenderAscii(content) } // RenderSuccess renders a success message with specific styling diff --git a/pkg/utils/markdown_utils.go b/pkg/utils/markdown_utils.go index 605938fa9..da5579ba5 100644 --- a/pkg/utils/markdown_utils.go +++ b/pkg/utils/markdown_utils.go @@ -11,13 +11,15 @@ import ( "github.com/cloudposse/atmos/pkg/ui/markdown" l "github.com/charmbracelet/log" - t "golang.org/x/term" ) // render is the global markdown renderer instance initialized via InitializeMarkdown var render *markdown.Renderer func PrintErrorMarkdown(title string, err error, suggestion string) { + if err == nil { + return + } if render == nil { LogError(err) return @@ -41,6 +43,24 @@ func PrintErrorMarkdown(title string, err error, suggestion string) { } } +// PrintfErrorMarkdown prints a formatted error message in markdown format +func PrintfErrorMarkdown(format string, a ...interface{}) { + if render == nil { + LogError(fmt.Errorf(format, a...)) + return + } + var markdown string + var renderErr error + markdown, renderErr = render.RenderErrorf(format, a...) + if renderErr != nil { + LogError(renderErr) + LogError(fmt.Errorf(format, a...)) + return + } + _, err := os.Stderr.WriteString(fmt.Sprint(markdown + "\n")) + LogError(err) +} + func PrintErrorMarkdownAndExit(title string, err error, suggestion string) { PrintErrorMarkdown(title, err, suggestion) os.Exit(1) @@ -55,11 +75,7 @@ func PrintfMarkdown(format string, a ...interface{}) { message := fmt.Sprintf(format, a...) var markdown string var renderErr error - if !t.IsTerminal(int(os.Stdout.Fd())) { - markdown, renderErr = render.RenderAscii(message) - } else { - markdown, renderErr = render.Render(message) - } + markdown, renderErr = render.Render(message) if renderErr != nil { LogErrorAndExit(renderErr) } diff --git a/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden index 0d3427fc0..2b724a90c 100644 --- a/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_--help.stdout.golden @@ -53,4 +53,7 @@ Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos [subcommand] --help for more information about a command. + +Use atmos [subcommand] --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden index 71b66c2d6..ea0c89e6c 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden @@ -30,4 +30,7 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos about --help for more information about a command. + +Use atmos about --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden index bcab309a8..182c64123 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_non-existent.stderr.golden @@ -7,6 +7,6 @@ Unknown command non-existent for atmos about • Learn about atmos - $ atmos about + $ atmos about diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden index 863af373d..5f01eae5e 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden @@ -38,4 +38,7 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis [subcommand] --help for more information about a command. + +Use atmos atlantis [subcommand] --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden index 7127acb0c..a834da175 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden @@ -50,4 +50,7 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis generate [subcommand] --help for more information about a command. + +Use atmos atlantis generate [subcommand] --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden index 7127acb0c..a834da175 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden @@ -50,4 +50,7 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis generate [subcommand] --help for more information about a command. + +Use atmos atlantis generate [subcommand] --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden index 38ebe1f1b..b465d068f 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden @@ -137,4 +137,7 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis generate repo-config --help for more information about a command. + +Use atmos atlantis generate repo-config --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden index 38ebe1f1b..b465d068f 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden @@ -137,4 +137,7 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis generate repo-config --help for more information about a command. + +Use atmos atlantis generate repo-config --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden index 863af373d..5f01eae5e 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden @@ -38,4 +38,7 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos atlantis [subcommand] --help for more information about a command. + +Use atmos atlantis [subcommand] --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden b/tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden index 3c9b7660e..f643ea84d 100644 --- a/tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden @@ -4,7 +4,7 @@ "terraform": { "base_path": "components/terraform", "apply_auto_approve": false, - "append_user_agent": "Atmos/test (Cloud Posse; +https://atmos.tools)", + "append_user_agent": "Atmos/0.0.1 (Cloud Posse; +https://atmos.tools)", "deploy_run_init": true, "init_run_reconfigure": true, "auto_generate_backend_file": false, @@ -123,15 +123,15 @@ "base_path": "" }, "initialized": true, - "stacksBaseAbsolutePath": "/Users/matt/src/github.com/cloudposse/atmos/examples/demo-stacks/stacks", + "stacksBaseAbsolutePath": "/home/samtholiya/cloudpose/atmos/examples/demo-stacks/stacks", "includeStackAbsolutePaths": [ - "/Users/matt/src/github.com/cloudposse/atmos/examples/demo-stacks/stacks/deploy/**/*" + "/home/samtholiya/cloudpose/atmos/examples/demo-stacks/stacks/deploy/**/*" ], "excludeStackAbsolutePaths": [ - "/Users/matt/src/github.com/cloudposse/atmos/examples/demo-stacks/stacks/**/_defaults.yaml" + "/home/samtholiya/cloudpose/atmos/examples/demo-stacks/stacks/**/_defaults.yaml" ], - "terraformDirAbsolutePath": "/Users/matt/src/github.com/cloudposse/atmos/examples/demo-stacks/components/terraform", - "helmfileDirAbsolutePath": "/Users/matt/src/github.com/cloudposse/atmos/examples/demo-stacks", + "terraformDirAbsolutePath": "/home/samtholiya/cloudpose/atmos/examples/demo-stacks/components/terraform", + "helmfileDirAbsolutePath": "/home/samtholiya/cloudpose/atmos/examples/demo-stacks", "default": false, "version": { "Check": { diff --git a/tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden b/tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden index de0d09a67..aa3ad5c24 100644 --- a/tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden @@ -3,7 +3,7 @@ components: terraform: base_path: components/terraform apply_auto_approve: false - append_user_agent: Atmos/test (Cloud Posse; +https://atmos.tools) + append_user_agent: Atmos/0.0.1 (Cloud Posse; +https://atmos.tools) deploy_run_init: true init_run_reconfigure: true auto_generate_backend_file: false @@ -32,13 +32,13 @@ settings: list_merge_strategy: "" inject_github_token: true initialized: true -stacksBaseAbsolutePath: /Users/matt/src/github.com/cloudposse/atmos/examples/demo-stacks/stacks +stacksBaseAbsolutePath: /home/samtholiya/cloudpose/atmos/examples/demo-stacks/stacks includeStackAbsolutePaths: - - /Users/matt/src/github.com/cloudposse/atmos/examples/demo-stacks/stacks/deploy/**/* + - /home/samtholiya/cloudpose/atmos/examples/demo-stacks/stacks/deploy/**/* excludeStackAbsolutePaths: - - /Users/matt/src/github.com/cloudposse/atmos/examples/demo-stacks/stacks/**/_defaults.yaml -terraformDirAbsolutePath: /Users/matt/src/github.com/cloudposse/atmos/examples/demo-stacks/components/terraform -helmfileDirAbsolutePath: /Users/matt/src/github.com/cloudposse/atmos/examples/demo-stacks + - /home/samtholiya/cloudpose/atmos/examples/demo-stacks/stacks/**/_defaults.yaml +terraformDirAbsolutePath: /home/samtholiya/cloudpose/atmos/examples/demo-stacks/components/terraform +helmfileDirAbsolutePath: /home/samtholiya/cloudpose/atmos/examples/demo-stacks default: false validate: editorconfig: diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden index 0949dde02..f718082b4 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden @@ -50,4 +50,7 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos helmfile [subcommand] --help for more information about a command. + +Use atmos helmfile [subcommand] --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden index 5d0222302..374d4e8dc 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden @@ -38,4 +38,7 @@ Global Flags: -s, --stack string atmos helmfile -s -Use  atmos helmfile apply --help for more information about a command. + +Use atmos helmfile apply --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden index 5d0222302..374d4e8dc 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden @@ -38,4 +38,7 @@ Global Flags: -s, --stack string atmos helmfile -s -Use  atmos helmfile apply --help for more information about a command. + +Use atmos helmfile apply --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden index 2482b28ea..f718082b4 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden @@ -50,9 +50,7 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos helmfile [subcommand] --help for more information about a command. -╭──────────────────────────────────────────────────────────────╮ -│ Update available! 0.0.1 » 1.157.0 │ -│ Atmos Releases: https://github.com/cloudposse/atmos/releases │ -│ Install Atmos: https://atmos.tools/install │ -╰──────────────────────────────────────────────────────────────╯ + +Use atmos helmfile [subcommand] --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden index 64896737a..395698d40 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden @@ -41,7 +41,7 @@ Valid subcommands are: – Execute a terraform - $ atmos terraform [sub-command] -s + $ atmos terraform [sub-command] -s For more information, refer to the docs https://atmos.tools/cli/commands/terraform/usage diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden index d989ac67c..b4a6c2ddd 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden @@ -94,6 +94,9 @@ Global Flags: Examples: – Execute a terraform -  $ atmos terraform [sub-command] -s  +  $ atmos terraform [sub-command] -s  + + +Use atmos terraform [subcommand] --help for more information about a command. + -Use  atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden index 517448d14..2a0b22371 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden @@ -99,6 +99,9 @@ Global Flags: Examples: – Execute a terraform -  $ atmos terraform [sub-command] -s  +  $ atmos terraform [sub-command] -s  + + +Use atmos terraform [subcommand] --help for more information about a command. + -Use  atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden index 9698aa24f..2ae9dfc38 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden @@ -57,6 +57,9 @@ Global Flags: Examples: – Apply changes to a terraform component -  $ atmos terraform apply -s  +  $ atmos terraform apply -s  + + +Use atmos terraform apply --help for more information about a command. + -Use  atmos terraform apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden index 9698aa24f..2ae9dfc38 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden @@ -57,6 +57,9 @@ Global Flags: Examples: – Apply changes to a terraform component -  $ atmos terraform apply -s  +  $ atmos terraform apply -s  + + +Use atmos terraform apply --help for more information about a command. + -Use  atmos terraform apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index d989ac67c..b4a6c2ddd 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -94,6 +94,9 @@ Global Flags: Examples: – Execute a terraform -  $ atmos terraform [sub-command] -s  +  $ atmos terraform [sub-command] -s  + + +Use atmos terraform [subcommand] --help for more information about a command. + -Use  atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden index a3a0b7d04..92efd7ec5 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden @@ -42,7 +42,7 @@ Valid subcommands are: – Execute a terraform - $ atmos terraform [sub-command] -s + $ atmos terraform [sub-command] -s For more information, refer to the docs https://atmos.tools/cli/commands/terraform/usage diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden index 58f9da279..00cfb4869 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden @@ -72,4 +72,7 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos validate editorconfig --help for more information about a command. + +Use atmos validate editorconfig --help for more information about a command. + + diff --git a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden index 58f9da279..00cfb4869 100644 --- a/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden @@ -72,4 +72,7 @@ Global Flags: '/dev/null'): atmos --redirect-stderr /dev/stdout -Use  atmos validate editorconfig --help for more information about a command. + +Use atmos validate editorconfig --help for more information about a command. + + From 2881ff41482d422f7c7771bfde0b969f305b486f Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 4 Feb 2025 22:04:35 +0100 Subject: [PATCH 43/64] fix manual render issue --- internal/exec/terraform_outputs.go | 2 +- internal/exec/validate_stacks.go | 3 ++- internal/exec/vendor_component_utils.go | 2 +- internal/exec/vendor_model.go | 2 +- internal/exec/vendor_model_component.go | 2 +- internal/exec/vendor_utils.go | 2 +- internal/tui/templates/term/term_writer.go | 6 +++--- pkg/list/list_workflows.go | 2 +- pkg/ui/markdown/renderer.go | 6 +++--- .../TestCLICommands_atmos_helmfile_help.stdout.golden | 5 +++++ .../TestCLICommands_atmos_terraform_--help.stdout.golden | 2 +- ...os_terraform_--help_alias_subcommand_check.stdout.golden | 2 +- ...stCLICommands_atmos_terraform_apply_--help.stdout.golden | 2 +- ...TestCLICommands_atmos_terraform_apply_help.stdout.golden | 2 +- .../TestCLICommands_atmos_terraform_help.stdout.golden | 2 +- 15 files changed, 24 insertions(+), 18 deletions(-) diff --git a/internal/exec/terraform_outputs.go b/internal/exec/terraform_outputs.go index 6b5a4af2f..b2e039d3e 100644 --- a/internal/exec/terraform_outputs.go +++ b/internal/exec/terraform_outputs.go @@ -233,7 +233,7 @@ func GetTerraformOutput( s.Style = theme.Styles.Link var opts []tea.ProgramOption - if !term.CheckTTYSupportForStdout() { + if !term.IsTTYSupportForStdout() { // set tea.WithInput(nil) workaround tea program not run on not TTY mod issue opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)} u.LogTrace("No TTY detected. Falling back to basic output. This can happen when no terminal is attached or when commands are pipelined.") diff --git a/internal/exec/validate_stacks.go b/internal/exec/validate_stacks.go index f2786602e..194bbc111 100644 --- a/internal/exec/validate_stacks.go +++ b/internal/exec/validate_stacks.go @@ -17,6 +17,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/cloudposse/atmos/internal/tui/templates/term" cfg "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/schema" "github.com/cloudposse/atmos/pkg/ui/theme" @@ -36,7 +37,7 @@ func ExecuteValidateStacksCmd(cmd *cobra.Command, args []string) error { s.Style = theme.Styles.Link var opts []tea.ProgramOption - if !CheckTTYSupport() { + if !term.IsTTYSupportForStdout() { // Workaround for non-TTY environments opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)} u.LogTrace("No TTY detected. Falling back to basic output. This can happen when no terminal is attached or when commands are pipelined.") diff --git a/internal/exec/vendor_component_utils.go b/internal/exec/vendor_component_utils.go index 30e9af44d..8c3a4714f 100644 --- a/internal/exec/vendor_component_utils.go +++ b/internal/exec/vendor_component_utils.go @@ -363,7 +363,7 @@ func ExecuteComponentVendorInternal( } var opts []tea.ProgramOption // Disable TUI if no TTY support is available - if !term.CheckTTYSupportForStdout() { + if !term.IsTTYSupportForStdout() { opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)} u.LogWarning("TTY is not supported. Running in non-interactive mode") } diff --git a/internal/exec/vendor_model.go b/internal/exec/vendor_model.go index 8ddab4b1e..b860aa7c9 100644 --- a/internal/exec/vendor_model.go +++ b/internal/exec/vendor_model.go @@ -87,7 +87,7 @@ func newModelAtmosVendorInternal(pkgs []pkgAtmosVendor, dryRun bool, atmosConfig if len(pkgs) == 0 { return modelVendor{done: true}, nil } - isTTY := term.CheckTTYSupportForStdout() + isTTY := term.IsTTYSupportForStdout() var vendorPks []pkgVendor for _, pkg := range pkgs { p := pkgVendor{ diff --git a/internal/exec/vendor_model_component.go b/internal/exec/vendor_model_component.go index 7e460b4f8..f64aee4a7 100644 --- a/internal/exec/vendor_model_component.go +++ b/internal/exec/vendor_model_component.go @@ -52,7 +52,7 @@ func newModelComponentVendorInternal(pkgs []pkgComponentVendor, dryRun bool, atm vendorPks = append(vendorPks, vendorPkg) } - tty := term.CheckTTYSupportForStdout() + tty := term.IsTTYSupportForStdout() return modelVendor{ packages: vendorPks, spinner: s, diff --git a/internal/exec/vendor_utils.go b/internal/exec/vendor_utils.go index bc098c0a9..80d102bc1 100644 --- a/internal/exec/vendor_utils.go +++ b/internal/exec/vendor_utils.go @@ -418,7 +418,7 @@ func ExecuteAtmosVendorInternal( // Run TUI to process packages if len(packages) > 0 { var opts []tea.ProgramOption - if !term.CheckTTYSupportForStdout() { + if !term.IsTTYSupportForStdout() { // set tea.WithInput(nil) workaround tea program not run on not TTY mod issue on non TTY mode https://github.com/charmbracelet/bubbletea/issues/761 opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)} u.LogWarning("No TTY detected. Falling back to basic output. This can happen when no terminal is attached or when commands are pipelined.") diff --git a/internal/tui/templates/term/term_writer.go b/internal/tui/templates/term/term_writer.go index aa988510e..97b6a4e87 100644 --- a/internal/tui/templates/term/term_writer.go +++ b/internal/tui/templates/term/term_writer.go @@ -30,7 +30,7 @@ func NewResponsiveWriter(w io.Writer) io.Writer { return w } - if !CheckTTYSupportForStdout() { + if !IsTTYSupportForStdout() { return w } @@ -79,14 +79,14 @@ func (w *TerminalWriter) GetWidth() uint { } // CheckTTYSupportStdout checks if stdout supports TTY for displaying the progress UI. -func CheckTTYSupportForStdout() bool { +func IsTTYSupportForStdout() bool { fd := int(os.Stdout.Fd()) isTerminal := term.IsTerminal(fd) return isTerminal } // CheckTTYSupportStderr checks if stderr supports TTY for displaying the progress UI. -func CheckTTYSupportForStderr() bool { +func IsTTYSupportForStderr() bool { fd := int(os.Stderr.Fd()) isTerminal := term.IsTerminal(fd) return isTerminal diff --git a/pkg/list/list_workflows.go b/pkg/list/list_workflows.go index f517e1e40..7d020cbb2 100644 --- a/pkg/list/list_workflows.go +++ b/pkg/list/list_workflows.go @@ -199,7 +199,7 @@ func FilterAndListWorkflows(fileFlag string, listConfig schema.ListConfig, forma default: // If format is empty or "table", use table format - if format == "" && term.CheckTTYSupportForStdout() { + if format == "" && term.IsTTYSupportForStdout() { // Create a styled table for TTY t := table.New(). Border(lipgloss.ThickBorder()). diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index 4401908c1..adea9cb8f 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -58,7 +58,7 @@ func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Render func (r *Renderer) Render(content string) (string, error) { var rendered string var err error - if term.CheckTTYSupportForStdout() { + if term.IsTTYSupportForStdout() { rendered, err = r.renderer.Render(content) } else { // Fallback to ASCII rendering for non-TTY stdout @@ -76,7 +76,7 @@ func (r *Renderer) Render(content string) (string, error) { for _, line := range lines { trimmed := strings.TrimSpace(line) - if strings.HasPrefix(trimmed, "$") { + if strings.HasPrefix(trimmed, "$") && term.IsTTYSupportForStdout() { // Add custom styling for command examples styled := purpleStyle.Styled(line) result = append(result, " "+styled) @@ -149,7 +149,7 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error // RenderErrorf renders an error message with specific styling func (r *Renderer) RenderErrorf(content string, args ...interface{}) (string, error) { - if term.CheckTTYSupportForStderr() { + if term.IsTTYSupportForStderr() { return r.Render(content) } // Fallback to ASCII rendering for non-TTY stderr diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden index f718082b4..5bae2775e 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden @@ -54,3 +54,8 @@ Global Flags: Use atmos helmfile [subcommand] --help for more information about a command. +╭──────────────────────────────────────────────────────────────╮ +│ Update available! 0.0.1 » 1.158.0 │ +│ Atmos Releases: https://github.com/cloudposse/atmos/releases │ +│ Install Atmos: https://atmos.tools/install │ +╰──────────────────────────────────────────────────────────────╯ diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden index b4a6c2ddd..9877b3eff 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden @@ -94,7 +94,7 @@ Global Flags: Examples: – Execute a terraform -  $ atmos terraform [sub-command] -s  + $ atmos terraform [sub-command] -s Use atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden index 2a0b22371..f0ce6335a 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden @@ -99,7 +99,7 @@ Global Flags: Examples: – Execute a terraform -  $ atmos terraform [sub-command] -s  + $ atmos terraform [sub-command] -s Use atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden index 2ae9dfc38..2fb4324d0 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden @@ -57,7 +57,7 @@ Global Flags: Examples: – Apply changes to a terraform component -  $ atmos terraform apply -s  + $ atmos terraform apply -s Use atmos terraform apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden index 2ae9dfc38..2fb4324d0 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden @@ -57,7 +57,7 @@ Global Flags: Examples: – Apply changes to a terraform component -  $ atmos terraform apply -s  + $ atmos terraform apply -s Use atmos terraform apply --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index b4a6c2ddd..9877b3eff 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -94,7 +94,7 @@ Global Flags: Examples: – Execute a terraform -  $ atmos terraform [sub-command] -s  + $ atmos terraform [sub-command] -s Use atmos terraform [subcommand] --help for more information about a command. From eeeb4cb536fdf90436b856b5676072843d28a8e3 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 4 Feb 2025 22:18:07 +0100 Subject: [PATCH 44/64] Update cmd/validate_component.go Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- cmd/validate_component.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/validate_component.go b/cmd/validate_component.go index 9be90ec1a..01685477d 100644 --- a/cmd/validate_component.go +++ b/cmd/validate_component.go @@ -29,7 +29,7 @@ var validateComponentCmd = &cobra.Command{ u.PrintErrorMarkdownAndExit("", err, "") } - m := fmt.Sprintf("component '%s' in stack '%s' validated successfully\n", component, stack) + m := fmt.Sprintf("component `%s` in stack `%s` validated successfully\n", component, stack) u.PrintMessageInColor(m, theme.Colors.Success) }, } From 66116ab293bb6bed5fe8fb8e59622885771d27d9 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 4 Feb 2025 22:19:02 +0100 Subject: [PATCH 45/64] Update internal/exec/atlantis_generate_repo_config.go Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- internal/exec/atlantis_generate_repo_config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/exec/atlantis_generate_repo_config.go b/internal/exec/atlantis_generate_repo_config.go index c08fa4b81..4efbe50d8 100644 --- a/internal/exec/atlantis_generate_repo_config.go +++ b/internal/exec/atlantis_generate_repo_config.go @@ -444,7 +444,7 @@ func ExecuteAtlantisGenerateRepoConfig( if configTemplate, ok = atmosConfig.Integrations.Atlantis.ConfigTemplates[settingsAtlantisConfigTemplateName]; !ok { return errors.Errorf("# Missing Atlantis Config Template\n\n"+ "## Configuration Issue\n\n"+ - "The Atlantis config template **'%s'** is referenced in `settings.atlantis.config_template_name`, "+ + "The Atlantis config template **`%s`** is referenced in `settings.atlantis.config_template_name`, "+ "but it is **not defined** in `integrations.atlantis.config_templates` inside `atmos.yaml`. "+ "Please update `atmos.yaml` to include the missing template.", settingsAtlantisConfigTemplateName) } From f90e81eb5887c6dad65bb3c3260535c99333a730 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 4 Feb 2025 22:19:44 +0100 Subject: [PATCH 46/64] Update cmd/docs.go Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- cmd/docs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/docs.go b/cmd/docs.go index ed319de13..54a0a15d5 100644 --- a/cmd/docs.go +++ b/cmd/docs.go @@ -69,7 +69,7 @@ var docsCmd = &cobra.Command{ u.PrintErrorMarkdownAndExit("", err, "") } if !componentPathExists { - u.PrintErrorMarkdownAndExit("", fmt.Errorf("Component `%s` not found in path: '%s'", info.Component, componentPath), "") + u.PrintErrorMarkdownAndExit("", fmt.Errorf("Component `%s` not found in path: `%s`", info.Component, componentPath), "") } readmePath := filepath.Join(componentPath, "README.md") From cd58e7b7f9acdaa8966c962fb46521e6074f55b8 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 4 Feb 2025 22:20:12 +0100 Subject: [PATCH 47/64] Update cmd/cmd_utils.go Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- cmd/cmd_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index ab8bea341..06ffd7f5a 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -135,7 +135,7 @@ func addCommandWithAlias(parentCmd *cobra.Command, alias string, parts []string) // If the command doesn't exist, create it if cmd == nil { - u.LogErrorAndExit(fmt.Errorf("subcommand '%s' not found for alias '%s'", parts[0], alias)) + u.LogErrorAndExit(fmt.Errorf("subcommand `%s` not found for alias `%s`", parts[0], alias)) } // If there are more parts, recurse for the next level From 5a4068a22f6c42718e74a4b4aabcecd76a939ad5 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 4 Feb 2025 22:25:25 +0100 Subject: [PATCH 48/64] updated error message for stack and components missing --- internal/exec/utils.go | 4 ++-- .../TestCLICommands_atmos_helmfile_apply.stderr.golden | 6 +++++- ...s_terraform_plan_non-existent_in_workspace.stderr.golden | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/exec/utils.go b/internal/exec/utils.go index 8abccb771..7caafc3f7 100644 --- a/internal/exec/utils.go +++ b/internal/exec/utils.go @@ -287,13 +287,13 @@ func ProcessStacks( ) (schema.ConfigAndStacksInfo, error) { // Check if stack was provided if checkStack && len(configAndStacksInfo.Stack) < 1 { - message := fmt.Sprintf("`stack` is required. Usage: `atmos %s -s `", configAndStacksInfo.ComponentType) + message := fmt.Sprintf("`stack` is required.\n\nUsage:\n\n`atmos %s -s `", configAndStacksInfo.ComponentType) return configAndStacksInfo, errors.New(message) } // Check if component was provided if len(configAndStacksInfo.ComponentFromArg) < 1 { - message := fmt.Sprintf("`component` is required. Usage: `atmos %s `", configAndStacksInfo.ComponentType) + message := fmt.Sprintf("`component` is required.\n\nUsage:\n\n`atmos %s `", configAndStacksInfo.ComponentType) return configAndStacksInfo, errors.New(message) } diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden index 7be94f4d1..1c05feccb 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply.stderr.golden @@ -1,6 +1,10 @@ # Error -stack is required. Usage: atmos helmfile -s +stack is required. + +Usage: + +atmos helmfile -s diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden index 2a93739cf..7c139cc9b 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_plan_non-existent_in_workspace.stderr.golden @@ -1,6 +1,10 @@ # Error -stack is required. Usage: atmos terraform -s +stack is required. + +Usage: + +atmos terraform -s From e1fba8a81ace751acc396bce8a675a438cfb286d Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 4 Feb 2025 22:30:48 +0100 Subject: [PATCH 49/64] fix flag help --- cmd/terraform_commands.go | 4 +++- ...tmos_terraform_--help_alias_subcommand_check.stdout.golden | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/terraform_commands.go b/cmd/terraform_commands.go index b86d06b16..4bf68722e 100644 --- a/cmd/terraform_commands.go +++ b/cmd/terraform_commands.go @@ -1,9 +1,11 @@ package cmd import ( + "fmt" "os" h "github.com/cloudposse/atmos/pkg/hooks" + "github.com/cloudposse/atmos/pkg/version" "github.com/spf13/cobra" ) @@ -253,7 +255,7 @@ Arguments: // attachTerraformCommands attaches static Terraform commands to a provided parent command func attachTerraformCommands(parentCmd *cobra.Command) { - parentCmd.PersistentFlags().String("append-user-agent", "", "Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. Example: 'Atmos/%s (Cloud Posse; +https://atmos.tools)'. This flag works with almost all commands.") + parentCmd.PersistentFlags().String("append-user-agent", "", fmt.Sprintf("Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. Example: 'Atmos/%s (Cloud Posse; +https://atmos.tools)'. This flag works with almost all commands.", version.Version)) parentCmd.PersistentFlags().Bool("skip-init", false, "Skip running 'terraform init' before executing the command") commands := getTerraformCommands() diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden index f0ce6335a..46a4be79c 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden @@ -63,7 +63,7 @@ Flags: --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. - Example: 'Atmos/%s (Cloud Posse; + Example: 'Atmos/0.0.1 (Cloud Posse; +https://atmos.tools)'. This flag works with almost all commands. From 1d95b24852c387d5a71958d0ea1aa41e647883fd Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 4 Feb 2025 22:36:26 +0100 Subject: [PATCH 50/64] Update pkg/ui/markdown/renderer.go Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- pkg/ui/markdown/renderer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index adea9cb8f..e99210200 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -138,7 +138,7 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error } if suggestion != "" { - if strings.HasPrefix(suggestion, "http") { + if strings.HasPrefix(suggestion, "https://") || strings.HasPrefix(suggestion, "http://"){ content += fmt.Sprintf("\nFor more information, refer to the [docs](%s)", suggestion) } else { content += suggestion From 55063083ecbfa8ade91c26d649df895b41d7ab41 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 21:37:15 +0000 Subject: [PATCH 51/64] [autofix.ci] apply automated fixes --- pkg/ui/markdown/renderer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index e99210200..071afa5d2 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -138,7 +138,7 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error } if suggestion != "" { - if strings.HasPrefix(suggestion, "https://") || strings.HasPrefix(suggestion, "http://"){ + if strings.HasPrefix(suggestion, "https://") || strings.HasPrefix(suggestion, "http://") { content += fmt.Sprintf("\nFor more information, refer to the [docs](%s)", suggestion) } else { content += suggestion From 5faaa7d450a2177968cad55380a1ec2e8d45ad46 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 4 Feb 2025 23:12:18 +0100 Subject: [PATCH 52/64] fix the snapshots --- .../TestCLICommands_atmos_describe_config.stdout.golden | 2 +- .../TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden | 2 +- .../snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden | 2 +- .../TestCLICommands_atmos_terraform_--help.stdout.golden | 2 +- ..._atmos_terraform_--help_alias_subcommand_check.stdout.golden | 2 +- .../TestCLICommands_atmos_terraform_apply_--help.stdout.golden | 2 +- .../TestCLICommands_atmos_terraform_apply_help.stdout.golden | 2 +- .../TestCLICommands_atmos_terraform_help.stdout.golden | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden b/tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden index b98dae8a2..40e44840c 100644 --- a/tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden @@ -4,7 +4,7 @@ "terraform": { "base_path": "components/terraform", "apply_auto_approve": false, - "append_user_agent": "Atmos/0.0.1 (Cloud Posse; +https://atmos.tools)", + "append_user_agent": "Atmos/test (Cloud Posse; +https://atmos.tools)", "deploy_run_init": true, "init_run_reconfigure": true, "auto_generate_backend_file": false, diff --git a/tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden b/tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden index 2520ed00d..19b2c2f36 100644 --- a/tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden @@ -3,7 +3,7 @@ components: terraform: base_path: components/terraform apply_auto_approve: false - append_user_agent: Atmos/0.0.1 (Cloud Posse; +https://atmos.tools) + append_user_agent: Atmos/test (Cloud Posse; +https://atmos.tools) deploy_run_init: true init_run_reconfigure: true auto_generate_backend_file: false diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden index 5bae2775e..dc57589e3 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden @@ -55,7 +55,7 @@ Use atmos helmfile [subcommand] --help for more information about a command. ╭──────────────────────────────────────────────────────────────╮ -│ Update available! 0.0.1 » 1.158.0 │ +│ Update available! test » 1.158.0 │ │ Atmos Releases: https://github.com/cloudposse/atmos/releases │ │ Install Atmos: https://atmos.tools/install │ ╰──────────────────────────────────────────────────────────────╯ diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden index 9877b3eff..5aea9b04a 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden @@ -58,7 +58,7 @@ Flags: --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. - Example: 'Atmos/%s (Cloud Posse; + Example: 'Atmos/test (Cloud Posse; +https://atmos.tools)'. This flag works with almost all commands. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden index 46a4be79c..a9dc8911c 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden @@ -63,7 +63,7 @@ Flags: --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. - Example: 'Atmos/0.0.1 (Cloud Posse; + Example: 'Atmos/test (Cloud Posse; +https://atmos.tools)'. This flag works with almost all commands. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden index 2fb4324d0..749b5aa54 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden @@ -26,7 +26,7 @@ Global Flags: --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. - Example: 'Atmos/%s (Cloud Posse; + Example: 'Atmos/test (Cloud Posse; +https://atmos.tools)'. This flag works with almost all commands. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden index 2fb4324d0..749b5aa54 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden @@ -26,7 +26,7 @@ Global Flags: --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. - Example: 'Atmos/%s (Cloud Posse; + Example: 'Atmos/test (Cloud Posse; +https://atmos.tools)'. This flag works with almost all commands. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index 9877b3eff..5aea9b04a 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -58,7 +58,7 @@ Flags: --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. - Example: 'Atmos/%s (Cloud Posse; + Example: 'Atmos/test (Cloud Posse; +https://atmos.tools)'. This flag works with almost all commands. From de042b9888f1137645e12707cf56e86d2eb87b67 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 5 Feb 2025 00:17:22 +0100 Subject: [PATCH 53/64] fixed workflow error message format --- internal/exec/workflow_utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/exec/workflow_utils.go b/internal/exec/workflow_utils.go index 568e878fe..61f30b233 100644 --- a/internal/exec/workflow_utils.go +++ b/internal/exec/workflow_utils.go @@ -109,12 +109,12 @@ func ExecuteWorkflow( workflowFileName := filepath.Base(workflowPath) workflowFileName = strings.TrimSuffix(workflowFileName, filepath.Ext(workflowFileName)) - failedMsg := theme.Colors.Error.Sprintf("\nStep '%s' failed!", step.Name) + failedMsg := fmt.Sprintf("\nStep '%s' failed!", step.Name) u.LogDebug(fmt.Sprintf("\nCommand failed: %s", command)) u.LogDebug(fmt.Sprintf("Error: %v", err)) - resumeMsg := theme.Colors.Success.Sprintf( + resumeMsg := fmt.Sprintf( "\nTo resume the workflow from this step, run:\natmos workflow %s -f %s --from-step %s", workflow, workflowFileName, From 8738804c7f0ee0861778526c5e33d857026f3dc8 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 5 Feb 2025 00:49:21 +0100 Subject: [PATCH 54/64] workflow UX updated --- cmd/workflow.go | 4 ++-- internal/exec/workflow.go | 13 ++++++++++++- ...workflow_pla_--file_workflow1.stderr.golden | 14 ++++++++++++++ ...workflow_pla_--file_workflow1.stdout.golden | 0 tests/test-cases/complete.yaml | 18 ++++++++++++++++++ 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 tests/snapshots/TestCLICommands_atmos_workflow_pla_--file_workflow1.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_workflow_pla_--file_workflow1.stdout.golden diff --git a/cmd/workflow.go b/cmd/workflow.go index 14d16e798..bb8588918 100644 --- a/cmd/workflow.go +++ b/cmd/workflow.go @@ -52,8 +52,8 @@ var workflowCmd = &cobra.Command{ // Format common error messages if strings.Contains(err.Error(), "does not exist") { u.PrintErrorMarkdownAndExit("File Not Found", fmt.Errorf("`%v` was not found", workflowFile), "") - } else if strings.Contains(err.Error(), "does not have the") { - u.PrintErrorMarkdownAndExit("Invalid Workflow", err, "") + } else if strings.Contains(err.Error(), "No workflow exists with the name") { + u.PrintErrorMarkdownAndExit("Invalid Workflow Name", err, "") } else { // For other errors, use the standard error handler u.PrintErrorMarkdownAndExit("", err, "") diff --git a/internal/exec/workflow.go b/internal/exec/workflow.go index ab901a729..23e4d1665 100644 --- a/internal/exec/workflow.go +++ b/internal/exec/workflow.go @@ -3,8 +3,11 @@ package exec import ( "errors" "fmt" + "maps" "os" "path/filepath" + "sort" + "strings" "github.com/spf13/cobra" @@ -114,7 +117,15 @@ func ExecuteWorkflowCmd(cmd *cobra.Command, args []string) error { workflowConfig = workflowManifest.Workflows if i, ok := workflowConfig[workflow]; !ok { - return fmt.Errorf("the workflow manifest '%s' does not have the '%s' workflow defined", workflowPath, workflow) + errorMarkdown := fmt.Sprintf("No workflow exists with the name `%s`\n\nAvailable workflows are:", workflow) + validWorkflows := []string{} + for w := range maps.Keys(workflowConfig) { + validWorkflows = append(validWorkflows, fmt.Sprintf("\n- %s", w)) + } + // sorting so that the output is deterministic + sort.Sort(sort.StringSlice(validWorkflows)) + errorMarkdown += strings.Join(validWorkflows, "") + return fmt.Errorf(errorMarkdown) } else { workflowDefinition = i } diff --git a/tests/snapshots/TestCLICommands_atmos_workflow_pla_--file_workflow1.stderr.golden b/tests/snapshots/TestCLICommands_atmos_workflow_pla_--file_workflow1.stderr.golden new file mode 100644 index 000000000..6a75c7880 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_workflow_pla_--file_workflow1.stderr.golden @@ -0,0 +1,14 @@ + +# Invalid Workflow Name + +No workflow exists with the name pla + +Available workflows are: + +• terraform-plan-all-tenant1-ue2-dev +• terraform-plan-all-test-components +• terraform-plan-test-component-override-2-all-stacks +• terraform-plan-test-component-override-3-all-stacks +• test-1 + + diff --git a/tests/snapshots/TestCLICommands_atmos_workflow_pla_--file_workflow1.stdout.golden b/tests/snapshots/TestCLICommands_atmos_workflow_pla_--file_workflow1.stdout.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test-cases/complete.yaml b/tests/test-cases/complete.yaml index be9acae76..5374e016b 100644 --- a/tests/test-cases/complete.yaml +++ b/tests/test-cases/complete.yaml @@ -15,3 +15,21 @@ tests: - 'ERRO ATMOS_SHLVL \(11\) exceeds maximum allowed depth \(10\)' - "ERRO exit status 1" exit_code: 1 + - name: atmos workflow pla --file workflow1 + enabled: true + snapshot: true + description: "Ensure atmos workflow pla --file workflow1 runs successfully." + workdir: "fixtures/scenarios/complete/" + command: "atmos" + args: + - "workflow" + - "pla" + - "--file" + - "workflow1" + expect: + diff: [] + stderr: + - "No workflow exists" + - "test-1" + - "terraform-plan-all-test-components" + exit_code: 1 \ No newline at end of file From c66dbfa1ef6627dacb50eae28185780de25e5bea Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 5 Feb 2025 01:08:47 +0100 Subject: [PATCH 55/64] Update cmd/cmd_utils.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- cmd/cmd_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 06ffd7f5a..dc3608c13 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -670,5 +670,5 @@ func showUsageExample(cmd *cobra.Command, details string) { suggestion = exampleContent.Suggestion details += "\n## Usage Examples:\n" + exampleContent.Content } - u.PrintErrorMarkdownAndExit("Incorrect Usage", fmt.Errorf(details), suggestion) + u.PrintErrorMarkdownAndExit("Incorrect Usage", errors.New(details), suggestion) } From c0ab2d4ced617e35bb6332d86935f9a82b9f6fa4 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 5 Feb 2025 19:41:09 +0100 Subject: [PATCH 56/64] small updates --- cmd/cmd_utils.go | 2 +- cmd/list_components.go | 2 +- cmd/list_workflows.go | 6 +++--- pkg/utils/markdown_utils.go | 7 +++++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index e194c2f34..06f796938 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -670,7 +670,7 @@ func showUsageExample(cmd *cobra.Command, details string) { suggestion = exampleContent.Suggestion details += "\n## Usage Examples:\n" + exampleContent.Content } - u.PrintErrorMarkdownAndExit("Incorrect Usage", fmt.Errorf(details), suggestion) + u.PrintInvalidUsageErrorAndExit(errors.New(details)) } // Contains checks if a slice of strings contains an exact match for the target string. diff --git a/cmd/list_components.go b/cmd/list_components.go index 89cfb16f6..6f1d68841 100644 --- a/cmd/list_components.go +++ b/cmd/list_components.go @@ -29,7 +29,7 @@ var listComponentsCmd = &cobra.Command{ stackFlag, err := flags.GetString("stack") if err != nil { - u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `stack` flag: `%v`", err), "") + u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `stack` flag: `%v`", err)) return } diff --git a/cmd/list_workflows.go b/cmd/list_workflows.go index b15287f43..85cc6dfda 100644 --- a/cmd/list_workflows.go +++ b/cmd/list_workflows.go @@ -26,19 +26,19 @@ var listWorkflowsCmd = &cobra.Command{ fileFlag, err := flags.GetString("file") if err != nil { - u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `file` flag: %v", err), "") + u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `file` flag: %v", err)) return } formatFlag, err := flags.GetString("format") if err != nil { - u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `format` flag: %v", err), "") + u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `format` flag: %v", err)) return } delimiterFlag, err := flags.GetString("delimiter") if err != nil { - u.PrintErrorMarkdownAndExit("Invalid Usage", fmt.Errorf("Error getting the `delimiter` flag: %v", err), "") + u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `delimiter` flag: %v", err)) return } diff --git a/pkg/utils/markdown_utils.go b/pkg/utils/markdown_utils.go index da5579ba5..48a9c83c6 100644 --- a/pkg/utils/markdown_utils.go +++ b/pkg/utils/markdown_utils.go @@ -9,6 +9,8 @@ import ( "github.com/cloudposse/atmos/pkg/schema" "github.com/cloudposse/atmos/pkg/ui/markdown" + "golang.org/x/text/cases" + "golang.org/x/text/language" l "github.com/charmbracelet/log" ) @@ -27,6 +29,7 @@ func PrintErrorMarkdown(title string, err error, suggestion string) { if title == "" { title = "Error" } + title = cases.Title(language.English).String(title) errorMarkdown, renderErr := render.RenderError(title, err.Error(), suggestion) if renderErr != nil { LogError(err) @@ -66,6 +69,10 @@ func PrintErrorMarkdownAndExit(title string, err error, suggestion string) { os.Exit(1) } +func PrintInvalidUsageErrorAndExit(err error) { + PrintErrorMarkdownAndExit("Invalid Usage", err, "") +} + func PrintfMarkdown(format string, a ...interface{}) { if render == nil { _, err := os.Stdout.WriteString(fmt.Sprintf(format, a...)) From 316fc49ef548bb9f9aa05229d2ff29958bca0fcd Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 5 Feb 2025 18:42:08 +0000 Subject: [PATCH 57/64] [autofix.ci] apply automated fixes --- cmd/cmd_utils.go | 2 +- cmd/list_components.go | 2 +- cmd/list_workflows.go | 6 +++--- go.mod | 2 +- pkg/utils/markdown_utils.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 06f796938..68b2d97ef 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -670,7 +670,7 @@ func showUsageExample(cmd *cobra.Command, details string) { suggestion = exampleContent.Suggestion details += "\n## Usage Examples:\n" + exampleContent.Content } - u.PrintInvalidUsageErrorAndExit(errors.New(details)) + u.PrintInvalidUsageErrorAndExit(errors.New(details), suggestion) } // Contains checks if a slice of strings contains an exact match for the target string. diff --git a/cmd/list_components.go b/cmd/list_components.go index 6f1d68841..a88aeb039 100644 --- a/cmd/list_components.go +++ b/cmd/list_components.go @@ -29,7 +29,7 @@ var listComponentsCmd = &cobra.Command{ stackFlag, err := flags.GetString("stack") if err != nil { - u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `stack` flag: `%v`", err)) + u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `stack` flag: `%v`", err), "") return } diff --git a/cmd/list_workflows.go b/cmd/list_workflows.go index 85cc6dfda..c9a918382 100644 --- a/cmd/list_workflows.go +++ b/cmd/list_workflows.go @@ -26,19 +26,19 @@ var listWorkflowsCmd = &cobra.Command{ fileFlag, err := flags.GetString("file") if err != nil { - u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `file` flag: %v", err)) + u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `file` flag: %v", err), "") return } formatFlag, err := flags.GetString("format") if err != nil { - u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `format` flag: %v", err)) + u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `format` flag: %v", err), "") return } delimiterFlag, err := flags.GetString("delimiter") if err != nil { - u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `delimiter` flag: %v", err)) + u.PrintInvalidUsageErrorAndExit(fmt.Errorf("Error getting the `delimiter` flag: %v", err), "") return } diff --git a/go.mod b/go.mod index 0d1584c9c..ca2e7cbb9 100644 --- a/go.mod +++ b/go.mod @@ -58,6 +58,7 @@ require ( github.com/zclconf/go-cty v1.16.2 golang.org/x/oauth2 v0.26.0 golang.org/x/term v0.29.0 + golang.org/x/text v0.21.0 gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 @@ -293,7 +294,6 @@ require ( golang.org/x/net v0.34.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.30.0 // indirect - golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.9.0 // indirect golang.org/x/tools v0.29.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect diff --git a/pkg/utils/markdown_utils.go b/pkg/utils/markdown_utils.go index 48a9c83c6..51b03a013 100644 --- a/pkg/utils/markdown_utils.go +++ b/pkg/utils/markdown_utils.go @@ -69,7 +69,7 @@ func PrintErrorMarkdownAndExit(title string, err error, suggestion string) { os.Exit(1) } -func PrintInvalidUsageErrorAndExit(err error) { +func PrintInvalidUsageErrorAndExit(err error, suggestion string) { PrintErrorMarkdownAndExit("Invalid Usage", err, "") } From 7dc5ec77c4d2ba330e981289a98839a7f9e72770 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 5 Feb 2025 20:41:13 +0100 Subject: [PATCH 58/64] fix tests --- cmd/terraform.go | 1 + internal/tui/templates/help_printer.go | 3 ++- pkg/utils/markdown_utils.go | 2 +- pkg/version/version.go | 2 +- .../TestCLICommands_atmos_atlantis_--help.stdout.golden | 2 +- ...CLICommands_atmos_atlantis_generate_--help.stdout.golden | 2 +- ...stCLICommands_atmos_atlantis_generate_help.stdout.golden | 2 +- ...atmos_atlantis_generate_repo-config_--help.stdout.golden | 2 +- ...s_atmos_atlantis_generate_repo-config_help.stdout.golden | 2 +- .../TestCLICommands_atmos_atlantis_help.stdout.golden | 2 +- .../TestCLICommands_atmos_helmfile_--help.stdout.golden | 1 - ...estCLICommands_atmos_helmfile_apply_--help.stdout.golden | 2 +- .../TestCLICommands_atmos_helmfile_apply_help.stdout.golden | 2 +- .../TestCLICommands_atmos_helmfile_help.stdout.golden | 6 ------ .../TestCLICommands_atmos_terraform_--help.stdout.golden | 1 - ...os_terraform_--help_alias_subcommand_check.stdout.golden | 1 - ...stCLICommands_atmos_terraform_apply_--help.stdout.golden | 1 - ...TestCLICommands_atmos_terraform_apply_help.stdout.golden | 1 - .../TestCLICommands_atmos_terraform_help.stdout.golden | 1 - 19 files changed, 13 insertions(+), 23 deletions(-) diff --git a/cmd/terraform.go b/cmd/terraform.go index 1f4174236..86b5f86d5 100644 --- a/cmd/terraform.go +++ b/cmd/terraform.go @@ -26,6 +26,7 @@ func init() { // https://github.com/spf13/cobra/issues/739 terraformCmd.DisableFlagParsing = true terraformCmd.PersistentFlags().StringP("stack", "s", "", "atmos terraform -s ") + terraformCmd.PersistentFlags().Bool("", false, doubleDashHint) attachTerraformCommands(terraformCmd) RootCmd.AddCommand(terraformCmd) } diff --git a/internal/tui/templates/help_printer.go b/internal/tui/templates/help_printer.go index de20041f1..7c4b870ed 100644 --- a/internal/tui/templates/help_printer.go +++ b/internal/tui/templates/help_printer.go @@ -103,7 +103,8 @@ func (p *HelpFlagPrinter) PrintHelpFlag(flag *pflag.Flag) { descIndent := p.maxFlagLen + 4 description := flag.Usage - if flag.DefValue != "" { + // if Name is empty it is our double dash. + if flag.DefValue != "" && flag.Name != "" { description = fmt.Sprintf("%s (default %q)", description, flag.DefValue) } diff --git a/pkg/utils/markdown_utils.go b/pkg/utils/markdown_utils.go index 51b03a013..8b55807a5 100644 --- a/pkg/utils/markdown_utils.go +++ b/pkg/utils/markdown_utils.go @@ -70,7 +70,7 @@ func PrintErrorMarkdownAndExit(title string, err error, suggestion string) { } func PrintInvalidUsageErrorAndExit(err error, suggestion string) { - PrintErrorMarkdownAndExit("Invalid Usage", err, "") + PrintErrorMarkdownAndExit("Incorrect Usage", err, suggestion) } func PrintfMarkdown(format string, a ...interface{}) { diff --git a/pkg/version/version.go b/pkg/version/version.go index 7db05562c..fadab1954 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -2,4 +2,4 @@ package version // Version holds the current version of the Atmos CLI. // It can be set dynamically during build time using ldflags. -var Version = "0.0.1" // Default version; will be overridden during build +var Version = "test" // Default version; will be overridden during build diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden index 5f01eae5e..6af86a0e3 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden @@ -14,7 +14,7 @@ Available Commands: Flags: -- Use double dashes to separate Atmos-specific options from - native arguments and flags for the command. (default "false") + native arguments and flags for the command. -h, --help help for atlantis (default "false") diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden index a834da175..2738ca4ea 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden @@ -31,7 +31,7 @@ Global Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for - the command. (default "false") + the command. --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden index a834da175..2738ca4ea 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden @@ -31,7 +31,7 @@ Global Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for - the command. (default "false") + the command. --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden index b465d068f..ca6d79ed1 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden @@ -105,7 +105,7 @@ Global Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for - the command. (default "false") + the command. --clone-target-ref Clone the target reference with which to compare the current branch: atmos atlantis diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden index b465d068f..ca6d79ed1 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden @@ -105,7 +105,7 @@ Global Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for - the command. (default "false") + the command. --clone-target-ref Clone the target reference with which to compare the current branch: atmos atlantis diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden index 5f01eae5e..6af86a0e3 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden @@ -14,7 +14,7 @@ Available Commands: Flags: -- Use double dashes to separate Atmos-specific options from - native arguments and flags for the command. (default "false") + native arguments and flags for the command. -h, --help help for atlantis (default "false") diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden index f718082b4..4b759acf7 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden @@ -23,7 +23,6 @@ Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for the command. - (default "false") -h, --help help for helmfile (default "false") diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden index 374d4e8dc..c2f84bc46 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden @@ -16,7 +16,7 @@ Global Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for - the command. (default "false") + the command. --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden index 374d4e8dc..c2f84bc46 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden @@ -16,7 +16,7 @@ Global Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for - the command. (default "false") + the command. --logs-file string The file to write Atmos logs to. Logs can be written to any file or any standard file diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden index dc57589e3..4b759acf7 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden @@ -23,7 +23,6 @@ Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for the command. - (default "false") -h, --help help for helmfile (default "false") @@ -54,8 +53,3 @@ Global Flags: Use atmos helmfile [subcommand] --help for more information about a command. -╭──────────────────────────────────────────────────────────────╮ -│ Update available! test » 1.158.0 │ -│ Atmos Releases: https://github.com/cloudposse/atmos/releases │ -│ Install Atmos: https://atmos.tools/install │ -╰──────────────────────────────────────────────────────────────╯ diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden index 5aea9b04a..6a67de675 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden @@ -53,7 +53,6 @@ Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for the command. - (default "false") --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden index a9dc8911c..2f2634b88 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden @@ -58,7 +58,6 @@ Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for the command. - (default "false") --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden index 749b5aa54..8566e36a3 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden @@ -21,7 +21,6 @@ Global Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for the command. - (default "false") --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden index 749b5aa54..8566e36a3 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden @@ -21,7 +21,6 @@ Global Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for the command. - (default "false") --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index 5aea9b04a..6a67de675 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -53,7 +53,6 @@ Flags: -- Use double dashes to separate Atmos-specific options from native arguments and flags for the command. - (default "false") --append-user-agent string Sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent From d3790d0e584b360f8cc77905dd522047ef22ce29 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 5 Feb 2025 21:06:35 +0100 Subject: [PATCH 59/64] make error condition for custom command invalid config usefull --- cmd/cmd_utils.go | 4 ++-- pkg/ui/markdown/renderer.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 68b2d97ef..bb153bbdd 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -222,8 +222,8 @@ func preCustomCommand( } else { // truly invalid, nothing to do u.PrintErrorMarkdownAndExit("Invalid command", errors.New( - "no args, no steps, no sub-commands", - ), "") + fmt.Sprintf("no args, no steps, no sub-commands provided in config for `%s`", cmd.CommandPath()), + ), "https://atmos.tools/cli/configuration/commands") } } diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index 071afa5d2..02648cbe3 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -139,7 +139,7 @@ func (r *Renderer) RenderError(title, details, suggestion string) (string, error if suggestion != "" { if strings.HasPrefix(suggestion, "https://") || strings.HasPrefix(suggestion, "http://") { - content += fmt.Sprintf("\nFor more information, refer to the [docs](%s)", suggestion) + content += fmt.Sprintf("\n\nFor more information, refer to the [docs](%s)", suggestion) } else { content += suggestion } From ffc48a3dc67bef9d3c453e3a6bb01265cd9158c2 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 5 Feb 2025 22:52:54 +0100 Subject: [PATCH 60/64] fix custom command invalid error sentence --- cmd/cmd_utils.go | 2 +- tests/fixtures/scenarios/complete/atmos.yaml | 3 ++- ...CLICommands_atmos_invalidCommand.stderr.golden | 8 ++++++++ ...CLICommands_atmos_invalidCommand.stdout.golden | 0 tests/test-cases/complete.yaml | 15 ++++++++++++++- 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tests/snapshots/TestCLICommands_atmos_invalidCommand.stderr.golden create mode 100644 tests/snapshots/TestCLICommands_atmos_invalidCommand.stdout.golden diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index bb153bbdd..9462b17ac 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -222,7 +222,7 @@ func preCustomCommand( } else { // truly invalid, nothing to do u.PrintErrorMarkdownAndExit("Invalid command", errors.New( - fmt.Sprintf("no args, no steps, no sub-commands provided in config for `%s`", cmd.CommandPath()), + fmt.Sprintf("The `%s` command has no steps or subcommands configured.", cmd.CommandPath()), ), "https://atmos.tools/cli/configuration/commands") } } diff --git a/tests/fixtures/scenarios/complete/atmos.yaml b/tests/fixtures/scenarios/complete/atmos.yaml index 41811f20a..2ecc16336 100644 --- a/tests/fixtures/scenarios/complete/atmos.yaml +++ b/tests/fixtures/scenarios/complete/atmos.yaml @@ -243,7 +243,8 @@ commands: > /dev/null - chmod 600 ${KUBECONFIG} - echo ${KUBECONFIG} - + - name: "invalidCommand" + description: "This is an invalid command that neither has steps or sub command" # Integrations integrations: # Atlantis integration diff --git a/tests/snapshots/TestCLICommands_atmos_invalidCommand.stderr.golden b/tests/snapshots/TestCLICommands_atmos_invalidCommand.stderr.golden new file mode 100644 index 000000000..a34a282b3 --- /dev/null +++ b/tests/snapshots/TestCLICommands_atmos_invalidCommand.stderr.golden @@ -0,0 +1,8 @@ + +# Invalid Command + +The atmos invalidCommand command has no steps or subcommands configured. + +For more information, refer to the docs https://atmos.tools/cli/configuration/commands + + diff --git a/tests/snapshots/TestCLICommands_atmos_invalidCommand.stdout.golden b/tests/snapshots/TestCLICommands_atmos_invalidCommand.stdout.golden new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test-cases/complete.yaml b/tests/test-cases/complete.yaml index 5374e016b..15837d06e 100644 --- a/tests/test-cases/complete.yaml +++ b/tests/test-cases/complete.yaml @@ -32,4 +32,17 @@ tests: - "No workflow exists" - "test-1" - "terraform-plan-all-test-components" - exit_code: 1 \ No newline at end of file + exit_code: 1 + - name: atmos invalidCommand + enabled: true + snapshot: true + description: "Ensure atmos invalidCommand returns error" + workdir: "fixtures/scenarios/complete/" + command: "atmos" + args: + - "invalidCommand" + expect: + diff: [] + stderr: + - "command has no steps or subcommands configured" + exit_code: 1 From 865db1ecfc22d3eb05dca1f859b772c2f88df2b5 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Thu, 6 Feb 2025 20:28:31 +0100 Subject: [PATCH 61/64] update tests --- .../TestCLICommands_atmos_about_--help.stdout.golden | 2 +- .../TestCLICommands_atmos_atlantis_--help.stdout.golden | 2 +- ...LICommands_atmos_atlantis_generate_--help.stdout.golden | 2 +- ...tCLICommands_atmos_atlantis_generate_help.stdout.golden | 2 +- ...tmos_atlantis_generate_repo-config_--help.stdout.golden | 2 +- ..._atmos_atlantis_generate_repo-config_help.stdout.golden | 2 +- .../TestCLICommands_atmos_atlantis_help.stdout.golden | 2 +- .../TestCLICommands_atmos_helmfile_--help.stdout.golden | 2 +- ...stCLICommands_atmos_helmfile_apply_--help.stdout.golden | 2 +- ...TestCLICommands_atmos_helmfile_apply_help.stdout.golden | 2 +- .../TestCLICommands_atmos_helmfile_help.stdout.golden | 7 ++++++- .../TestCLICommands_atmos_terraform_--help.stdout.golden | 2 +- ...s_terraform_--help_alias_subcommand_check.stdout.golden | 2 +- ...tCLICommands_atmos_terraform_apply_--help.stdout.golden | 2 +- ...estCLICommands_atmos_terraform_apply_help.stdout.golden | 2 +- .../TestCLICommands_atmos_terraform_help.stdout.golden | 7 ++++++- 16 files changed, 26 insertions(+), 16 deletions(-) diff --git a/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden index ea0c89e6c..0322346e5 100644 --- a/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_about_--help.stdout.golden @@ -17,7 +17,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden index 6af86a0e3..94601cead 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_--help.stdout.golden @@ -25,7 +25,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden index 2738ca4ea..d0e592907 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_--help.stdout.golden @@ -37,7 +37,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden index 2738ca4ea..d0e592907 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden @@ -37,7 +37,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden index ca6d79ed1..639252dcd 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_--help.stdout.golden @@ -124,7 +124,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden index ca6d79ed1..639252dcd 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_generate_repo-config_help.stdout.golden @@ -124,7 +124,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden index 6af86a0e3..94601cead 100644 --- a/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_atlantis_help.stdout.golden @@ -25,7 +25,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden index 4b759acf7..86591cb0c 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden @@ -36,7 +36,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden index c2f84bc46..1517f59d8 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden @@ -22,7 +22,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden index c2f84bc46..1517f59d8 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden @@ -22,7 +22,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden index 4b759acf7..c7b95fdaf 100644 --- a/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden @@ -36,7 +36,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level @@ -53,3 +53,8 @@ Global Flags: Use atmos helmfile [subcommand] --help for more information about a command. +╭──────────────────────────────────────────────────────────────╮ +│ Update available! test » 1.160.2 │ +│ Atmos Releases: https://github.com/cloudposse/atmos/releases │ +│ Install Atmos: https://atmos.tools/install │ +╰──────────────────────────────────────────────────────────────╯ diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden index 6a67de675..a5c182e12 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden @@ -76,7 +76,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden index 2f2634b88..01ec4db07 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden @@ -81,7 +81,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden index 8566e36a3..7cc55866e 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden @@ -33,7 +33,7 @@ Global Flags: be written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden index 8566e36a3..7cc55866e 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_apply_help.stdout.golden @@ -33,7 +33,7 @@ Global Flags: be written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index 6a67de675..307f16c0c 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -76,7 +76,7 @@ Global Flags: written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null' (default - "/dev/stdout") + "/dev/stderr") --logs-level string Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level @@ -99,3 +99,8 @@ Examples: Use atmos terraform [subcommand] --help for more information about a command. +╭──────────────────────────────────────────────────────────────╮ +│ Update available! test » 1.160.2 │ +│ Atmos Releases: https://github.com/cloudposse/atmos/releases │ +│ Install Atmos: https://atmos.tools/install │ +╰──────────────────────────────────────────────────────────────╯ From 9a7e14a0738742cc439da22531599b6d95ab4412 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 9 Feb 2025 16:43:14 +0100 Subject: [PATCH 62/64] updated terraform help --- cmd/markdown/atmos_terraform_usage.md | 4 ++-- tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden | 4 ++-- .../TestCLICommands_atmos_terraform_--help.stdout.golden | 4 ++-- ...tmos_terraform_--help_alias_subcommand_check.stdout.golden | 4 ++-- .../TestCLICommands_atmos_terraform_help.stdout.golden | 4 ++-- ...TestCLICommands_atmos_terraform_non-existent.stderr.golden | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/markdown/atmos_terraform_usage.md b/cmd/markdown/atmos_terraform_usage.md index 841619cfd..3eb82f797 100644 --- a/cmd/markdown/atmos_terraform_usage.md +++ b/cmd/markdown/atmos_terraform_usage.md @@ -1,5 +1,5 @@ -– Execute a terraform +– Execute a terraform subcommand ``` - $ atmos terraform [sub-command] -s + $ atmos terraform [subcommand] -s ``` \ No newline at end of file diff --git a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden index 395698d40..6d96bdcd7 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform.stderr.golden @@ -39,9 +39,9 @@ Valid subcommands are: ## Usage Examples: -– Execute a terraform +– Execute a terraform subcommand - $ atmos terraform [sub-command] -s + $ atmos terraform [subcommand] -s For more information, refer to the docs https://atmos.tools/cli/commands/terraform/usage diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden index a5c182e12..6001c3a35 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help.stdout.golden @@ -92,8 +92,8 @@ Global Flags: Examples: -– Execute a terraform - $ atmos terraform [sub-command] -s +– Execute a terraform subcommand + $ atmos terraform [subcommand] -s Use atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden index 01ec4db07..c08724b29 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_--help_alias_subcommand_check.stdout.golden @@ -97,8 +97,8 @@ Global Flags: Examples: -– Execute a terraform - $ atmos terraform [sub-command] -s +– Execute a terraform subcommand + $ atmos terraform [subcommand] -s Use atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden index 307f16c0c..64f736b45 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_help.stdout.golden @@ -92,8 +92,8 @@ Global Flags: Examples: -– Execute a terraform - $ atmos terraform [sub-command] -s +– Execute a terraform subcommand + $ atmos terraform [subcommand] -s Use atmos terraform [subcommand] --help for more information about a command. diff --git a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden index 92efd7ec5..88f1a433a 100644 --- a/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden +++ b/tests/snapshots/TestCLICommands_atmos_terraform_non-existent.stderr.golden @@ -40,9 +40,9 @@ Valid subcommands are: ## Usage Examples: -– Execute a terraform +– Execute a terraform subcommand - $ atmos terraform [sub-command] -s + $ atmos terraform [subcommand] -s For more information, refer to the docs https://atmos.tools/cli/commands/terraform/usage From b3ea391ee11f17bfa8206a25b2ca7252a0f09f34 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Sun, 9 Feb 2025 16:58:26 +0100 Subject: [PATCH 63/64] readded this test --- tests/test-cases/log-level-validation.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test-cases/log-level-validation.yaml b/tests/test-cases/log-level-validation.yaml index e079144fe..21e2e1807 100644 --- a/tests/test-cases/log-level-validation.yaml +++ b/tests/test-cases/log-level-validation.yaml @@ -34,6 +34,9 @@ tests: env: ATMOS_LOGS_LEVEL: XTrace expect: + stderr: + - "XTrace" + - "Valid options are" diff: [] exit_code: 1 From 3e4cee8ccb59d31af86ec369e6a004d1b74f247c Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 12 Feb 2025 18:45:05 +0000 Subject: [PATCH 64/64] [autofix.ci] apply automated fixes --- cmd/list_stacks.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/list_stacks.go b/cmd/list_stacks.go index 33b8d77a6..979da4ca9 100644 --- a/cmd/list_stacks.go +++ b/cmd/list_stacks.go @@ -3,6 +3,7 @@ package cmd import ( "fmt" "strings" + "github.com/spf13/cobra" e "github.com/cloudposse/atmos/internal/exec" @@ -25,7 +26,7 @@ var listStacksCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { // Check Atmos configuration checkAtmosConfig() - output, err := listStacks(cmd) + output, err := listStacks(cmd) if err != nil { u.PrintErrorMarkdownAndExit("Error filtering stacks", err, "") return