Skip to content
Merged
Changes from all commits
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
21 changes: 7 additions & 14 deletions cmd/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package cmd

import (
"encoding/json"
"errors"
"fmt"
"os"
"time"
Expand Down Expand Up @@ -41,13 +40,10 @@ User profiles can be configured with a "config.yml" file in the profile director
}

profileNewCommand := &cobra.Command{
Use: "create",
Use: "create [profile]",
Short: "Create a new profile",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {

if len(args) == 0 {
return errors.New("create requires an argument")
}
newProfileName := args[0]

fromName, err := cmd.Flags().GetString(cobraext.ProfileFromFlagName)
Expand Down Expand Up @@ -75,12 +71,10 @@ User profiles can be configured with a "config.yml" file in the profile director
profileNewCommand.Flags().String(cobraext.ProfileFromFlagName, "", cobraext.ProfileFromFlagDescription)

profileDeleteCommand := &cobra.Command{
Use: "delete",
Use: "delete [profile]",
Short: "Delete a profile",
Args: cobra.ExactArgs(1),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice, probably we should review all subcommands to check if these options are needed in more places?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks like it would be good to add those validations in the other sub-commands.

Here it has been added for stack sub-commands too: #1412

RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("delete requires an argument")
}
profileName := args[0]

config, err := install.Configuration()
Expand Down Expand Up @@ -117,6 +111,7 @@ User profiles can be configured with a "config.yml" file in the profile director
profileListCommand := &cobra.Command{
Use: "list",
Short: "List available profiles",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
loc, err := locations.NewLocationManager()
if err != nil {
Expand Down Expand Up @@ -153,12 +148,10 @@ User profiles can be configured with a "config.yml" file in the profile director
profileListCommand.Flags().String(cobraext.ProfileFormatFlagName, tableFormat, cobraext.ProfileFormatFlagDescription)

profileUseCommand := &cobra.Command{
Use: "use",
Use: "use [profile]",
Short: "Sets the profile to use when no other is specified",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("use requires an argument")
}
profileName := args[0]

_, err := profile.LoadProfile(profileName)
Expand Down