Skip to content

Commit

Permalink
Merge pull request #1879 from rsteube/env-usage
Browse files Browse the repository at this point in the history
env: add use to completions
  • Loading branch information
rsteube authored Sep 28, 2023
2 parents 6d2777d + 62a92c1 commit ea3b7a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
25 changes: 18 additions & 7 deletions pkg/actions/env/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func init() {
"AWS_DEFAULT_OUTPUT": "Specifies the output format to use",
"AWS_DEFAULT_REGION": "The Default region name",
"AWS_EC2_METADATA_DISABLED": "Disables the use of the Amazon EC2 instance metadata service (IMDS)",
"AWS_ENDPOINT_URL": "Specifies the endpoint that is used for all service requests",
// "AWS_ENDPOINT_URL_<SERVICE>": "pecifies a custom endpoint that is used for a specific service, where <SERVICE> is replaced with the AWS service identifier. For example, Amazon DynamoDB has a serviceId of DynamoDB. For this service, the endpoint URL environment variable is AWS_ENDPOINT_URL_DYNAMODB.
"AWS_ENDPOINT_URL": "Specifies the endpoint that is used for all service requests",
"AWS_IGNORE_CONFIGURED_ENDPOINT_URLS": "If enabled, the AWS CLI ignores all custom endpoint configurations",
"AWS_MAX_ATTEMPTS": "Specifies a value of maximum retry attempts the AWS CLI retry handler uses",
"AWS_METADATA_SERVICE_NUM_ATTEMPTS": "retry multiple times before giving up",
Expand All @@ -42,22 +42,33 @@ func init() {
"AWS_WEB_IDENTITY_TOKEN_FILE": "Specifies the path to a file that contains an OAuth 2.0 access token",
},
VariableCompletion: map[string]carapace.Action{
"AWS_CA_BUNDLE": carapace.ActionFiles(),
"AWS_ACCESS_KEY_ID": carapace.ActionValues(),
"AWS_CA_BUNDLE": carapace.ActionFiles(),
"AWS_CLI_AUTO_PROMPT": carapace.ActionValuesDescribed(
"on", "full auto-prompt mode each time you attempt to run an aws command",
"on-partial", "partial auto-prompt mode",
).StyleF(style.ForKeyword),
"AWS_CONFIG_FILE": carapace.ActionFiles(),
"AWS_DATA_PATH": carapace.ActionDirectories().List(string(os.PathListSeparator)),
"AWS_DEFAULT_OUTPUT": aws.ActionOutputFormats(),
"AWS_DEFAULT_REGION": aws.ActionRegions(),
"AWS_EC2_METADATA_DISABLED": _bool,
"AWS_CLI_FILE_ENCODING": carapace.ActionValues(), // TODO encodings
"AWS_CONFIG_FILE": carapace.ActionFiles(),
"AWS_DATA_PATH": carapace.ActionDirectories().List(string(os.PathListSeparator)),
"AWS_DEFAULT_OUTPUT": aws.ActionOutputFormats(),
"AWS_DEFAULT_REGION": aws.ActionRegions(),
"AWS_EC2_METADATA_DISABLED": _bool,
"AWS_ENDPOINT_URL": carapace.ActionValues(),
// "AWS_ENDPOINT_URL_<SERVICE>": carapace.ActionValues(), // TODO
"AWS_IGNORE_CONFIGURED_ENDPOINT_URLS": _bool,
"AWS_MAX_ATTEMPTS": carapace.ActionValues(),
"AWS_METADATA_SERVICE_NUM_ATTEMPTS": carapace.ActionValues(),
"AWS_METADATA_SERVICE_TIMEOUT": carapace.ActionValues(),
"AWS_PAGER": bridge.ActionCarapaceBin().Split(),
"AWS_PROFILE": aws.ActionProfiles(),
"AWS_REGION": aws.ActionRegions(),
"AWS_RETRY_MODE": carapace.ActionValues("legacy", "standard", "adaptive"),
"AWS_ROLE_ARN": carapace.ActionValues(),
"AWS_ROLE_SESSION_NAME": carapace.ActionValues(),
"AWS_SECRET_ACCESS_KEY": carapace.ActionValues(),
"AWS_SHARED_CREDENTIALS_FILE": carapace.ActionFiles(),
"AWS_USE_FIPS_ENDPOINT": carapace.ActionValues(),
"AWS_WEB_IDENTITY_TOKEN_FILE": carapace.ActionFiles(),
},
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/actions/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ func ActionEnvironmentVariableValues(s string) carapace.Action {
if custom.Condition == nil || custom.Condition(c) {
if action, ok := custom.VariableCompletion[s]; ok {
found = true
return action
return action.Usage(custom.Variables[s])
}
}

for _, v := range knownVariables {
if action, ok := v.VariableCompletion[s]; ok {
found = true
return action
return action.Usage(v.Variables[s])
}
}
return carapace.ActionValues()
Expand Down

0 comments on commit ea3b7a4

Please sign in to comment.