Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
oleiade committed Jul 23, 2024
1 parent 972219e commit 3965239
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
10 changes: 5 additions & 5 deletions cmd/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,19 +390,19 @@ To run tests in the cloud, users are now invited to migrate to the "k6 cloud run

func exactCloudArgs() cobra.PositionalArgs {
return func(_ *cobra.Command, args []string) error {
const baseErrMsg = "the k6 cloud command expects either a subcommand such as `run` or `login`, or " +
const baseErrMsg = `the "k6 cloud" command expects either a subcommand such as "run" or "login", or ` +
"a single argument consisting in a path to a script/archive, or the `-` symbol instructing " +
"the command to read the test content from stdin"

if len(args) == 0 {
return fmt.Errorf(baseErrMsg + "; " + "received no arguments")
}

hasSubcommand := len(args) >= 1 && (args[0] == "run" || args[0] == "login")
if !hasSubcommand {
hasSubcommand := args[0] == "run" || args[0] == "login"
if len(args) > 1 && !hasSubcommand {
return fmt.Errorf(
baseErrMsg+"; "+"received %d arguments %q, and none of them is a subcommand",
len(args), strings.Join(args, " "),
baseErrMsg+"; "+"received %d arguments %q, and %s is not a valid subcommand",
len(args), strings.Join(args, " "), args[0],
)
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/cloud_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ func getCmdCloudLogin(gs *state.GlobalState) *cobra.Command {

// loginCloudCommand represents the 'cloud login' command
exampleText := getExampleText(gs, `
# Log in with an email/password.
# Log in with an email/password
{{.}} cloud login
# Store a token in k6's persistent configuration.
# Store a token in k6's persistent configuration
{{.}} cloud login -t <YOUR_TOKEN>
# Display the stored token.
# Display the stored token
{{.}} cloud login -s
# Reset the stored token.
# Reset the stored token
{{.}} cloud login -r`[1:])

loginCloudCommand := &cobra.Command{
Expand Down
8 changes: 2 additions & 6 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ func getCmdLogin(gs *state.GlobalState) *cobra.Command {
loginCmd := &cobra.Command{
Use: "login",
Short: "Authenticate with a service",
Long: `[deprecation notice]
This command is deprecated and will be removed in a future release. Please use the "k6 cloud login" command instead.
Authenticate with a service.
Long: `Authenticate with a service.
Logging into a service changes the default when just "-o [type]" is passed with
no parameters, you can always override the stored credentials by passing some
on the commandline.`,
Deprecated: `This command is deprecated and will be removed in a future release.
Please use the "k6 cloud login" command instead.
Deprecated: `and will be removed in a future release. Please use the "k6 cloud login" command instead.
`,
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Usage()
Expand Down
9 changes: 4 additions & 5 deletions cmd/login_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ func getCmdLoginCloud(gs *state.GlobalState) *cobra.Command {
loginCloudCommand := &cobra.Command{
Use: "cloud",
Short: "Authenticate with k6 Cloud",
Long: `[deprecation notice]
This command is deprecated and will be removed in a future release. Please use the
"k6 cloud login" command instead.
Authenticate with Grafana Cloud k6.
Long: `Authenticate with Grafana Cloud k6.
This will set the default token used when just "k6 run -o cloud" is passed.`,
Example: exampleText,
Args: cobra.NoArgs,
Deprecated: `and will be removed in a future release.
Please use the "k6 cloud login" command instead.
`,
RunE: func(cmd *cobra.Command, _ []string) error {
currentDiskConf, err := readDiskConfig(gs)
if err != nil {
Expand Down

0 comments on commit 3965239

Please sign in to comment.