From fe0706cf5474cd2d1fd4c3d4c6160bfed8deb35c Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Thu, 16 Jan 2025 01:17:43 +0100 Subject: [PATCH] fix atlantis command help and usage --- cmd/atlantis_generate_repo_config.go | 4 +++- tests/test-cases/help-and-usage.yaml | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cmd/atlantis_generate_repo_config.go b/cmd/atlantis_generate_repo_config.go index 65f6d253e..47e29a64b 100644 --- a/cmd/atlantis_generate_repo_config.go +++ b/cmd/atlantis_generate_repo_config.go @@ -14,9 +14,11 @@ var atlantisGenerateRepoConfigCmd = &cobra.Command{ Short: "Generate repository configuration for Atlantis", Long: "Generate the repository configuration file required for Atlantis to manage Terraform repositories.", FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false}, - Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { handleHelpRequest(cmd, args) + if len(args) > 0 { + showUsageAndExit(cmd, args) + } // Check Atmos configuration checkAtmosConfig() err := e.ExecuteAtlantisGenerateRepoConfigCmd(cmd, args) diff --git a/tests/test-cases/help-and-usage.yaml b/tests/test-cases/help-and-usage.yaml index 060e8adbc..681950885 100644 --- a/tests/test-cases/help-and-usage.yaml +++ b/tests/test-cases/help-and-usage.yaml @@ -431,3 +431,19 @@ tests: stderr: - "^$" exit_code: 0 + - name: atmos atlantis generate repo-config non-existant + enabled: true + description: "Should show usage for 'atmos atlantis generate repo-config non-existant'" + workdir: "../" + command: "atmos" + args: + - "atlantis" + - "generate" + - "repo-config" + - "--help" + expect: + stderr: + - "Error: Unknown command \"non-existant\" for \"atmos atlantis generate repo-config\"" + stderr: + - "^$" + exit_code: 0