From d428c0cfcdd21eeb5111756cce2af4bca6ee6b69 Mon Sep 17 00:00:00 2001 From: Quentin Brosse Date: Fri, 27 Mar 2020 16:58:59 +0100 Subject: [PATCH 1/2] feat(init): rename send-telemetry arg and improve usage --- internal/namespaces/init/init.go | 10 ++++---- internal/namespaces/init/init_test.go | 18 +++++++++++++ .../testdata/test-init-helper.stderr.golden | 25 +++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 internal/namespaces/init/init_test.go create mode 100644 internal/namespaces/init/testdata/test-init-helper.stderr.golden diff --git a/internal/namespaces/init/init.go b/internal/namespaces/init/init.go index f0629bfe8b..ded047a78e 100644 --- a/internal/namespaces/init/init.go +++ b/internal/namespaces/init/init.go @@ -77,12 +77,10 @@ func initCommand() *core.Command { ArgSpecs: core.ArgSpecs{ { Name: "secret-key", + Short: "Scaleway secret-key", ValidateFunc: core.ValidateSecretKey(), }, - { - Name: "region", - EnumValues: []string{"fr-par", "nl-ams"}, - }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), // `organization-id` is not required before `PreValidateFunc()`, but is required after `PreValidateFunc()`. // See workflow in cobra_utils.go/cobraRun(). // It is not required in the command line: the user is not obliged to type it. @@ -90,10 +88,12 @@ func initCommand() *core.Command { // If `organization-id` is not typed by the user, we set it in `PreValidateFunc()`. { Name: "organization-id", + Short: "Organization ID to use. If none is passed will use default organization ID from the config", ValidateFunc: core.ValidateOrganizationIDRequired(), }, { - Name: "send-usage", + Name: "send-telemetry", + Short: "Send usage statistics and diagnostics", }, { Name: "with-ssh-key", diff --git a/internal/namespaces/init/init_test.go b/internal/namespaces/init/init_test.go new file mode 100644 index 0000000000..397207e09f --- /dev/null +++ b/internal/namespaces/init/init_test.go @@ -0,0 +1,18 @@ +package init + +import ( + "testing" + + "github.com/scaleway/scaleway-cli/internal/core" +) + +func Test_Init(t *testing.T) { + t.Run("Helper", core.Test(&core.TestConfig{ + Commands: GetCommands(), + Cmd: "scw init --help", + Check: core.TestCheckCombine( + core.TestCheckGolden(), + core.TestCheckExitCode(0), + ), + })) +} diff --git a/internal/namespaces/init/testdata/test-init-helper.stderr.golden b/internal/namespaces/init/testdata/test-init-helper.stderr.golden new file mode 100644 index 0000000000..28cafa095c --- /dev/null +++ b/internal/namespaces/init/testdata/test-init-helper.stderr.golden @@ -0,0 +1,25 @@ +Initialize the active profile of the config located in /Users/qbrosse/.config/scw/config.yaml + +USAGE: + scw init [arg=value ...] + +ARGS: + [secret-key] Scaleway secret-key + [region] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + [organization-id] Organization ID to use. If none is passed will use default organization ID from the config + [send-telemetry] Send usage statistics and diagnostics + [with-ssh-key=true] Whether the ssh key for managing instances should be uploaded automatically + [install-autocomplete] Whether the autocomplete script should be installed during initialisation + [zone] Zone to target. If none is passed will use default zone from the config + +FLAGS: + -h, --help help for init + +GLOBAL FLAGS: + -D, --debug Enable debug mode + -o, --output string Output format: json or human + -p, --profile string The config profile to use + +SEE ALSO: + # Config management help + scw config --help From 317e0cdb39bb47719e878e3d42dc7a9219bd59eb Mon Sep 17 00:00:00 2001 From: Quentin Brosse Date: Fri, 27 Mar 2020 17:38:08 +0100 Subject: [PATCH 2/2] remove tests --- internal/namespaces/account/custom.go | 4 +-- internal/namespaces/init/init_test.go | 18 ------------- .../testdata/test-init-helper.stderr.golden | 25 ------------------- 3 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 internal/namespaces/init/init_test.go delete mode 100644 internal/namespaces/init/testdata/test-init-helper.stderr.golden diff --git a/internal/namespaces/account/custom.go b/internal/namespaces/account/custom.go index e871b410b8..cce38500c2 100644 --- a/internal/namespaces/account/custom.go +++ b/internal/namespaces/account/custom.go @@ -35,8 +35,8 @@ func sshKeyCommand() *core.Command { func initCommand() *core.Command { return &core.Command{ - Short: `Initiliaze SSH key`, - Long: `Initiliaze SSH key.`, + Short: `Initialize SSH key`, + Long: `Initialize SSH key.`, Namespace: "account", Resource: "ssh-key", Verb: "init", diff --git a/internal/namespaces/init/init_test.go b/internal/namespaces/init/init_test.go deleted file mode 100644 index 397207e09f..0000000000 --- a/internal/namespaces/init/init_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package init - -import ( - "testing" - - "github.com/scaleway/scaleway-cli/internal/core" -) - -func Test_Init(t *testing.T) { - t.Run("Helper", core.Test(&core.TestConfig{ - Commands: GetCommands(), - Cmd: "scw init --help", - Check: core.TestCheckCombine( - core.TestCheckGolden(), - core.TestCheckExitCode(0), - ), - })) -} diff --git a/internal/namespaces/init/testdata/test-init-helper.stderr.golden b/internal/namespaces/init/testdata/test-init-helper.stderr.golden deleted file mode 100644 index 28cafa095c..0000000000 --- a/internal/namespaces/init/testdata/test-init-helper.stderr.golden +++ /dev/null @@ -1,25 +0,0 @@ -Initialize the active profile of the config located in /Users/qbrosse/.config/scw/config.yaml - -USAGE: - scw init [arg=value ...] - -ARGS: - [secret-key] Scaleway secret-key - [region] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) - [organization-id] Organization ID to use. If none is passed will use default organization ID from the config - [send-telemetry] Send usage statistics and diagnostics - [with-ssh-key=true] Whether the ssh key for managing instances should be uploaded automatically - [install-autocomplete] Whether the autocomplete script should be installed during initialisation - [zone] Zone to target. If none is passed will use default zone from the config - -FLAGS: - -h, --help help for init - -GLOBAL FLAGS: - -D, --debug Enable debug mode - -o, --output string Output format: json or human - -p, --profile string The config profile to use - -SEE ALSO: - # Config management help - scw config --help