-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): add profile activate command (#1206)
- Loading branch information
1 parent
59677b5
commit 4216b26
Showing
14 changed files
with
175 additions
and
70 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
cmd/scw/testdata/test-all-usage-config-profile-activate-usage.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 | ||
🟥🟥🟥 STDERR️️ 🟥🟥🟥️ | ||
Mark a profile as active in the config file | ||
|
||
USAGE: | ||
scw config profile activate <profile-name ...> [arg=value ...] | ||
|
||
ARGS: | ||
profile-name | ||
|
||
FLAGS: | ||
-h, --help help for activate | ||
|
||
GLOBAL FLAGS: | ||
-c, --config string The path to the config file | ||
-D, --debug Enable debug mode | ||
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human") | ||
-p, --profile string The config profile to use |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package core | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"github.com/scaleway/scaleway-sdk-go/scw" | ||
) | ||
|
||
func AutocompleteProfileName() AutoCompleteArgFunc { | ||
return func(ctx context.Context, prefix string) AutocompleteSuggestions { | ||
res := AutocompleteSuggestions(nil) | ||
configPath := ExtractConfigPath(ctx) | ||
config, err := scw.LoadConfigFromPath(configPath) | ||
if err != nil { | ||
return res | ||
} | ||
|
||
for profileName := range config.Profiles { | ||
if strings.HasPrefix(profileName, prefix) { | ||
res = append(res, profileName) | ||
} | ||
} | ||
|
||
if strings.HasPrefix(scw.DefaultProfileName, prefix) { | ||
res = append(res, scw.DefaultProfileName) | ||
} | ||
return res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.