Skip to content

feat(init): rename send-telemetry arg and improve usage #818

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions internal/namespaces/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ 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.
// But it is required to make the request: this is why we use `ValidateOrganizationIDRequired().
// 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",
Expand Down
18 changes: 18 additions & 0 deletions internal/namespaces/init/init_test.go
Original file line number Diff line number Diff line change
@@ -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),
),
}))
}
25 changes: 25 additions & 0 deletions internal/namespaces/init/testdata/test-init-helper.stderr.golden
Original file line number Diff line number Diff line change
@@ -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