From f9390947d454f8e1c5e4aba1381be4b0e2cf6878 Mon Sep 17 00:00:00 2001 From: rsteube Date: Fri, 29 Sep 2023 21:31:23 +0200 Subject: [PATCH] env: optimize init --- pkg/actions/env/aws.go | 122 ++++++++--------- pkg/actions/env/carapace.go | 50 +++---- pkg/actions/env/cargo.go | 207 ++++++++++++++-------------- pkg/actions/env/common.go | 35 ++--- pkg/actions/env/common_unix.go | 37 ++--- pkg/actions/env/docker.go | 61 ++++----- pkg/actions/env/env.go | 18 ++- pkg/actions/env/env_test.go | 2 +- pkg/actions/env/gh.go | 58 ++++---- pkg/actions/env/git.go | 142 ++++++++++---------- pkg/actions/env/golang.go | 237 +++++++++++++++++---------------- pkg/actions/env/gradle.go | 27 ++-- pkg/actions/env/java.go | 19 +-- pkg/actions/env/maven.go | 23 ++-- pkg/actions/env/nocolor.go | 23 ++-- pkg/actions/env/node.go | 63 ++++----- pkg/actions/env/python.go | 128 +++++++++--------- pkg/actions/env/rust.go | 33 ++--- pkg/actions/env/starship.go | 59 ++++---- pkg/actions/env/terraform.go | 156 +++++++++++----------- pkg/actions/env/terragrunt.go | 120 +++++++++-------- pkg/actions/env/tofu.go | 156 +++++++++++----------- pkg/actions/env/xdg.go | 41 +++--- 23 files changed, 928 insertions(+), 889 deletions(-) diff --git a/pkg/actions/env/aws.go b/pkg/actions/env/aws.go index 0e6bc871b3..662f41256c 100644 --- a/pkg/actions/env/aws.go +++ b/pkg/actions/env/aws.go @@ -11,65 +11,67 @@ import ( ) func init() { - _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) - knownVariables["aws"] = variables{ - Condition: conditions.ConditionPath("aws"), - Variables: map[string]string{ - "AWS_ACCESS_KEY_ID": "Specifies an AWS access key associated with an IAM account", - "AWS_CA_BUNDLE": "Specifies the path to a certificate bundle to use for HTTPS certificate validation", - "AWS_CLI_AUTO_PROMPT": "Enables the auto-prompt for the AWS CLI version 2", - "AWS_CLI_FILE_ENCODING": "Specifies the encoding used for text files", - "AWS_CONFIG_FILE": "Specifies the location of the file that the AWS CLI uses to store configuration profiles", - "AWS_DATA_PATH": "A list of additional directories to check outside of the built-in search path of ~/.aws/models", - "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_": "pecifies a custom endpoint that is used for a specific service, where 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", - "AWS_METADATA_SERVICE_TIMEOUT": "The number of seconds before a connection to the instance metadata service should time out", - "AWS_PAGER": "Specifies the pager program used for output", - "AWS_PROFILE": "Specifies the name of the AWS CLI profile with the credentials and options to use", - "AWS_REGION": "The AWS SDK compatible environment variable that specifies the AWS Region to send the request to", - "AWS_RETRY_MODE": "Specifies which retry mode AWS CLI uses", - "AWS_ROLE_ARN": "Specifies the Amazon Resource Name (ARN) of an IAM role", - "AWS_ROLE_SESSION_NAME": "Specifies the name to attach to the role session", - "AWS_SECRET_ACCESS_KEY": "Specifies the secret key associated with the access key", - "AWS_SHARED_CREDENTIALS_FILE": "Specifies the location of the file that the AWS CLI uses to store access keys", - "AWS_USE_FIPS_ENDPOINT": "Federal Information Processing Standard (FIPS) endoint", - "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_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_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_": 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(), - }, + knownVariables["aws"] = func() variables { + _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) + return variables{ + Condition: conditions.ConditionPath("aws"), + Variables: map[string]string{ + "AWS_ACCESS_KEY_ID": "Specifies an AWS access key associated with an IAM account", + "AWS_CA_BUNDLE": "Specifies the path to a certificate bundle to use for HTTPS certificate validation", + "AWS_CLI_AUTO_PROMPT": "Enables the auto-prompt for the AWS CLI version 2", + "AWS_CLI_FILE_ENCODING": "Specifies the encoding used for text files", + "AWS_CONFIG_FILE": "Specifies the location of the file that the AWS CLI uses to store configuration profiles", + "AWS_DATA_PATH": "A list of additional directories to check outside of the built-in search path of ~/.aws/models", + "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_": "pecifies a custom endpoint that is used for a specific service, where 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", + "AWS_METADATA_SERVICE_TIMEOUT": "The number of seconds before a connection to the instance metadata service should time out", + "AWS_PAGER": "Specifies the pager program used for output", + "AWS_PROFILE": "Specifies the name of the AWS CLI profile with the credentials and options to use", + "AWS_REGION": "The AWS SDK compatible environment variable that specifies the AWS Region to send the request to", + "AWS_RETRY_MODE": "Specifies which retry mode AWS CLI uses", + "AWS_ROLE_ARN": "Specifies the Amazon Resource Name (ARN) of an IAM role", + "AWS_ROLE_SESSION_NAME": "Specifies the name to attach to the role session", + "AWS_SECRET_ACCESS_KEY": "Specifies the secret key associated with the access key", + "AWS_SHARED_CREDENTIALS_FILE": "Specifies the location of the file that the AWS CLI uses to store access keys", + "AWS_USE_FIPS_ENDPOINT": "Federal Information Processing Standard (FIPS) endoint", + "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_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_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_": 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(), + }, + } } } diff --git a/pkg/actions/env/carapace.go b/pkg/actions/env/carapace.go index 58810b3c22..c92dfbb650 100644 --- a/pkg/actions/env/carapace.go +++ b/pkg/actions/env/carapace.go @@ -6,30 +6,32 @@ import ( ) func init() { - _bool := carapace.ActionValuesDescribed("0", "disabled", "1", "enabled").StyleF(style.ForKeyword) - knownVariables["carapace"] = variables{ - Variables: map[string]string{ - "CARAPACE_COVERDIR": "coverage directory for sandbox tests", - "CARAPACE_ENV": "register get-env, set-env and unset-env", - "CARAPACE_HIDDEN": "show hidden commands/flags", - "CARAPACE_LENIENT": "allow unknown flags", - "CARAPACE_LOG": "enable logging", - "CARAPACE_MATCH": "match case insensitive", - "CARAPACE_SANDBOX": "mock context for sandbox tests", - "CARAPACE_ZSH_HASH_DIRS": "zsh hash directories", - }, - VariableCompletion: map[string]carapace.Action{ - "CARAPACE_COVERDIR": carapace.ActionDirectories(), - "CARAPACE_ENV": _bool, - "CARAPACE_HIDDEN": _bool, - "CARAPACE_LENIENT": _bool, - "CARAPACE_LOG": _bool, - "CARAPACE_MATCH": carapace.ActionValuesDescribed( - "0", "CASE_SENSITIVE", - "1", "CASE_INSENSITIVE", - ).StyleF(style.ForKeyword), - "CARAPACE_SANDBOX": carapace.ActionValues(), - }, + knownVariables["carapace"] = func() variables { + _bool := carapace.ActionValuesDescribed("0", "disabled", "1", "enabled").StyleF(style.ForKeyword) + return variables{ + Variables: map[string]string{ + "CARAPACE_COVERDIR": "coverage directory for sandbox tests", + "CARAPACE_ENV": "register get-env, set-env and unset-env", + "CARAPACE_HIDDEN": "show hidden commands/flags", + "CARAPACE_LENIENT": "allow unknown flags", + "CARAPACE_LOG": "enable logging", + "CARAPACE_MATCH": "match case insensitive", + "CARAPACE_SANDBOX": "mock context for sandbox tests", + "CARAPACE_ZSH_HASH_DIRS": "zsh hash directories", + }, + VariableCompletion: map[string]carapace.Action{ + "CARAPACE_COVERDIR": carapace.ActionDirectories(), + "CARAPACE_ENV": _bool, + "CARAPACE_HIDDEN": _bool, + "CARAPACE_LENIENT": _bool, + "CARAPACE_LOG": _bool, + "CARAPACE_MATCH": carapace.ActionValuesDescribed( + "0", "CASE_SENSITIVE", + "1", "CASE_INSENSITIVE", + ).StyleF(style.ForKeyword), + "CARAPACE_SANDBOX": carapace.ActionValues(), + }, + } } } diff --git a/pkg/actions/env/cargo.go b/pkg/actions/env/cargo.go index bf38989934..d734e2ba2d 100644 --- a/pkg/actions/env/cargo.go +++ b/pkg/actions/env/cargo.go @@ -9,108 +9,109 @@ import ( ) func init() { - _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) - knownVariables["cargo"] = variables{ - Condition: conditions.ConditionPath("cargo"), - Variables: map[string]string{ - "CARGO_BIN_NAME": "The name of the binary that is currently being compiled", - "CARGO_BUILD_DEP_INFO_BASEDIR": "Dep-info relative directory, see build.dep-info-basedir", - "CARGO_BUILD_INCREMENTAL": "Incremental compilation, see build.incremental", - "CARGO_BUILD_JOBS": "Number of parallel jobs, see build.jobs", - "CARGO_BUILD_RUSTC": "The rustc executable, see build.rustc", - "CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER": "The rustc wrapper for workspace members only, see build.rustc-workspace-wrapper", - "CARGO_BUILD_RUSTC_WRAPPER": "The rustc wrapper, see build.rustc-wrapper", - "CARGO_BUILD_RUSTDOCFLAGS": "Extra rustdoc flags, see build.rustdocflags", - "CARGO_BUILD_RUSTDOC": "The rustdoc executable, see build.rustdoc", - "CARGO_BUILD_RUSTFLAGS": "Extra rustc flags, see build.rustflags", - "CARGO_BUILD_TARGET_DIR": "The default output directory, see build.target-dir", - "CARGO_BUILD_TARGET": "The default target platform, see build.target", - "CARGO_CACHE_RUSTC_INFO": "If this is set to 0 then Cargo will not try to cache compiler version information", - "CARGO_CARGO_NEW_VCS": "The default source control system with cargo new, see cargo-new.vcs", - "CARGO_CFG_TARGET_ARCH": "The CPU target architecture", - "CARGO_CFG_TARGET_ENDIAN": "The CPU target endianness", - "CARGO_CFG_TARGET_ENV": "The target environment ABI", - "CARGO_CFG_TARGET_FAMILY": "The target family", - "CARGO_CFG_TARGET_FEATURE": "List of CPU target features enabled", - "CARGO_CFG_TARGET_OS": "The target operating system", - "CARGO_CFG_TARGET_POINTER_WIDTH": "The CPU pointer width", - "CARGO_CFG_TARGET_VENDOR": "The target vendor", - "CARGO_CFG_UNIX": "Set on unix-like platforms", - "CARGO_CFG_WINDOWS": "Set on windows-like platforms", - "CARGO_CRATE_NAME": "The name of the crate that is currently being compiled", - "CARGO_ENCODED_RUSTDOCFLAGS": "A list of custom flags separated by 0x1f (ASCII Unit Separator) to pass to all rustdoc invocations that Cargo performs", - "CARGO_ENCODED_RUSTFLAGS": "A list of custom flags separated by 0x1f (ASCII Unit Separator) to pass to all compiler invocations that Cargo performs", - "CARGO_FUTURE_INCOMPAT_REPORT_FREQUENCY": "How often we should generate a future incompat report notification, see future-incompat-report.frequency", - "CARGO_HOME": "Cargo maintains a local cache of the registry index and of git checkouts of crates", - "CARGO_HTTP_CAINFO": "The TLS certificate Certificate Authority file, see http.cainfo", - "CARGO_HTTP_CHECK_REVOKE": "Disables TLS certificate revocation checks, see http.check-revoke", - "CARGO_HTTP_DEBUG": "Enables HTTP debugging, see http.debug", - "CARGO_HTTP_LOW_SPEED_LIMIT": "The HTTP low-speed limit, see http.low-speed-limit", - "CARGO_HTTP_MULTIPLEXING": "Whether HTTP/2 multiplexing is used, see http.multiplexing", - "CARGO_HTTP_PROXY": "Enables HTTP proxy, see http.proxy", - "CARGO_HTTP_SSL_VERSION": "The TLS version to use, see http.ssl-version", - "CARGO_HTTP_TIMEOUT": "The HTTP timeout, see http.timeout", - "CARGO_HTTP_USER_AGENT": "The HTTP user-agent header, see http.user-agent", - "CARGO_INCREMENTAL": "If this is set to 1 then Cargo will force incremental compilation to be enabled for the current compilation, and when set to 0 it will force disabling it", - "CARGO_INSTALL_ROOT": "The default directory for cargo install, see install.root", - "CARGO_LOG": "Cargo uses the env_logger crate to display debug log messages", - "CARGO_MAKEFLAGS": "Contains parameters needed for Cargo’s jobserver implementation to parallelize subprocesses", - "CARGO_MANIFEST_DIR": "The directory containing the manifest of your package", - "CARGO_MANIFEST_LINKS": "the manifest links value", - "CARGO_NET_GIT_FETCH_WITH_CLI": "Enables the use of the git executable to fetch, see net.git-fetch-with-cli", - "CARGO_NET_OFFLINE": "Offline mode, see net.offline", - "CARGO_NET_RETRY": "Number of times to retry network errors, see net.retry", - "CARGO_PKG_AUTHORS": "Colon separated list of authors from the manifest of your package", - "CARGO_PKG_DESCRIPTION": "The description from the manifest of your package", - "CARGO_PKG_HOMEPAGE": "The home page from the manifest of your package", - "CARGO_PKG_LICENSE_FILE": "The license file from the manifest of your package", - "CARGO_PKG_LICENSE": "The license from the manifest of your package", - "CARGO_PKG_NAME": "The name of your package", - "CARGO_PKG_README": "Path to the README file of your package", - "CARGO_PKG_REPOSITORY": "The repository from the manifest of your package", - "CARGO_PKG_RUST_VERSION": "The Rust version from the manifest of your package", - "CARGO_PKG_VERSION_MAJOR": "The major version of your package", - "CARGO_PKG_VERSION_MINOR": "The minor version of your package", - "CARGO_PKG_VERSION_PATCH": "The patch version of your package", - "CARGO_PKG_VERSION_PRE": "The pre-release version of your package", - "CARGO_PKG_VERSION": "The full version of your package", - "CARGO_PRIMARY_PACKAGE": "This environment variable will be set if the package being built is primary", - "CARGO_REGISTRY_DEFAULT": "Default registry for the --registry flag, see registry.default", - "CARGO_REGISTRY_TOKEN": "Authentication token for crates.io, see registry.token", - "CARGO_TARGET_DIR": "Location of where to place all generated artifacts, relative to the current working directory", - "CARGO_TARGET_TMPDIR": "Only set when building integration test or benchmark code", - "CARGO_TERM_COLOR": "The default color mode, see term.color", - "CARGO_TERM_PROGRESS_WHEN": "The default progress bar showing mode, see term.progress.when", - "CARGO_TERM_PROGRESS_WIDTH": "The default progress bar width, see term.progress.width", - "CARGO_TERM_QUIET": "Quiet mode, see term.quiet", - "CARGO_TERM_VERBOSE": "The default terminal verbosity, see term.verbose", - }, - VariableCompletion: map[string]carapace.Action{ - "CARGO_BUILD_DEP_INFO_BASEDIR": carapace.ActionDirectories(), - "CARGO_BUILD_INCREMENTAL": _bool, - "CARGO_BUILD_RUSTFLAGS": bridge.ActionCarapaceBin("rustc").Split(), - "CARGO_BUILD_RUSTDOCFLAGS": bridge.ActionCarapaceBin("rustdoc").Split(), - "CARGO_BUILD_TARGET_DIR": carapace.ActionDirectories(), - "CARGO_CARGO_NEW_VCS": carapace.ActionValues("git", "hg", "pijul", "fossil", "none"), - "CARGO_HOME": carapace.ActionDirectories(), - "CARGO_HTTP_CHECK_REVOKE": _bool, - "CARGO_HTTP_DEBUG": _bool, - "CARGO_HTTP_MULTIPLEXING": _bool, - "CARGO_HTTP_USER_AGENT": http.ActionUserAgents(), - "CARGO_INCREMENTAL": carapace.ActionStyledValuesDescribed( - "0", "force disabled,", style.Red, - "1", "force enabled", style.Green, - ), - "CARGO_LOG": carapace.ActionValues("debug", "info", "warn", "error", "trace").StyleF(style.ForLogLevel), - "CARGO_MANIFEST_DIR": carapace.ActionDirectories(), - "CARGO_NET_GIT_FETCH_WITH_CLI": _bool, - "CARGO_NET_OFFLINE": _bool, - "CARGO_TARGET_DIR": carapace.ActionDirectories(), - "CARGO_TERM_COLOR": carapace.ActionValues("auto", "always", "never").StyleF(style.ForKeyword), - "CARGO_TERM_QUIET": _bool, - "CARGO_TERM_VERBOSE": _bool, - // TODO more completions - }, + knownVariables["cargo"] = func() variables { + _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) + return variables{ + Condition: conditions.ConditionPath("cargo"), + Variables: map[string]string{ + "CARGO_BIN_NAME": "The name of the binary that is currently being compiled", + "CARGO_BUILD_DEP_INFO_BASEDIR": "Dep-info relative directory, see build.dep-info-basedir", + "CARGO_BUILD_INCREMENTAL": "Incremental compilation, see build.incremental", + "CARGO_BUILD_JOBS": "Number of parallel jobs, see build.jobs", + "CARGO_BUILD_RUSTC": "The rustc executable, see build.rustc", + "CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER": "The rustc wrapper for workspace members only, see build.rustc-workspace-wrapper", + "CARGO_BUILD_RUSTC_WRAPPER": "The rustc wrapper, see build.rustc-wrapper", + "CARGO_BUILD_RUSTDOCFLAGS": "Extra rustdoc flags, see build.rustdocflags", + "CARGO_BUILD_RUSTDOC": "The rustdoc executable, see build.rustdoc", + "CARGO_BUILD_RUSTFLAGS": "Extra rustc flags, see build.rustflags", + "CARGO_BUILD_TARGET_DIR": "The default output directory, see build.target-dir", + "CARGO_BUILD_TARGET": "The default target platform, see build.target", + "CARGO_CACHE_RUSTC_INFO": "If this is set to 0 then Cargo will not try to cache compiler version information", + "CARGO_CARGO_NEW_VCS": "The default source control system with cargo new, see cargo-new.vcs", + "CARGO_CFG_TARGET_ARCH": "The CPU target architecture", + "CARGO_CFG_TARGET_ENDIAN": "The CPU target endianness", + "CARGO_CFG_TARGET_ENV": "The target environment ABI", + "CARGO_CFG_TARGET_FAMILY": "The target family", + "CARGO_CFG_TARGET_FEATURE": "List of CPU target features enabled", + "CARGO_CFG_TARGET_OS": "The target operating system", + "CARGO_CFG_TARGET_POINTER_WIDTH": "The CPU pointer width", + "CARGO_CFG_TARGET_VENDOR": "The target vendor", + "CARGO_CFG_UNIX": "Set on unix-like platforms", + "CARGO_CFG_WINDOWS": "Set on windows-like platforms", + "CARGO_CRATE_NAME": "The name of the crate that is currently being compiled", + "CARGO_ENCODED_RUSTDOCFLAGS": "A list of custom flags separated by 0x1f (ASCII Unit Separator) to pass to all rustdoc invocations that Cargo performs", + "CARGO_ENCODED_RUSTFLAGS": "A list of custom flags separated by 0x1f (ASCII Unit Separator) to pass to all compiler invocations that Cargo performs", + "CARGO_FUTURE_INCOMPAT_REPORT_FREQUENCY": "How often we should generate a future incompat report notification, see future-incompat-report.frequency", + "CARGO_HOME": "Cargo maintains a local cache of the registry index and of git checkouts of crates", + "CARGO_HTTP_CAINFO": "The TLS certificate Certificate Authority file, see http.cainfo", + "CARGO_HTTP_CHECK_REVOKE": "Disables TLS certificate revocation checks, see http.check-revoke", + "CARGO_HTTP_DEBUG": "Enables HTTP debugging, see http.debug", + "CARGO_HTTP_LOW_SPEED_LIMIT": "The HTTP low-speed limit, see http.low-speed-limit", + "CARGO_HTTP_MULTIPLEXING": "Whether HTTP/2 multiplexing is used, see http.multiplexing", + "CARGO_HTTP_PROXY": "Enables HTTP proxy, see http.proxy", + "CARGO_HTTP_SSL_VERSION": "The TLS version to use, see http.ssl-version", + "CARGO_HTTP_TIMEOUT": "The HTTP timeout, see http.timeout", + "CARGO_HTTP_USER_AGENT": "The HTTP user-agent header, see http.user-agent", + "CARGO_INCREMENTAL": "If this is set to 1 then Cargo will force incremental compilation to be enabled for the current compilation, and when set to 0 it will force disabling it", + "CARGO_INSTALL_ROOT": "The default directory for cargo install, see install.root", + "CARGO_LOG": "Cargo uses the env_logger crate to display debug log messages", + "CARGO_MAKEFLAGS": "Contains parameters needed for Cargo’s jobserver implementation to parallelize subprocesses", + "CARGO_MANIFEST_DIR": "The directory containing the manifest of your package", + "CARGO_MANIFEST_LINKS": "the manifest links value", + "CARGO_NET_GIT_FETCH_WITH_CLI": "Enables the use of the git executable to fetch, see net.git-fetch-with-cli", + "CARGO_NET_OFFLINE": "Offline mode, see net.offline", + "CARGO_NET_RETRY": "Number of times to retry network errors, see net.retry", + "CARGO_PKG_AUTHORS": "Colon separated list of authors from the manifest of your package", + "CARGO_PKG_DESCRIPTION": "The description from the manifest of your package", + "CARGO_PKG_HOMEPAGE": "The home page from the manifest of your package", + "CARGO_PKG_LICENSE_FILE": "The license file from the manifest of your package", + "CARGO_PKG_LICENSE": "The license from the manifest of your package", + "CARGO_PKG_NAME": "The name of your package", + "CARGO_PKG_README": "Path to the README file of your package", + "CARGO_PKG_REPOSITORY": "The repository from the manifest of your package", + "CARGO_PKG_RUST_VERSION": "The Rust version from the manifest of your package", + "CARGO_PKG_VERSION_MAJOR": "The major version of your package", + "CARGO_PKG_VERSION_MINOR": "The minor version of your package", + "CARGO_PKG_VERSION_PATCH": "The patch version of your package", + "CARGO_PKG_VERSION_PRE": "The pre-release version of your package", + "CARGO_PKG_VERSION": "The full version of your package", + "CARGO_PRIMARY_PACKAGE": "This environment variable will be set if the package being built is primary", + "CARGO_REGISTRY_DEFAULT": "Default registry for the --registry flag, see registry.default", + "CARGO_REGISTRY_TOKEN": "Authentication token for crates.io, see registry.token", + "CARGO_TARGET_DIR": "Location of where to place all generated artifacts, relative to the current working directory", + "CARGO_TARGET_TMPDIR": "Only set when building integration test or benchmark code", + "CARGO_TERM_COLOR": "The default color mode, see term.color", + "CARGO_TERM_PROGRESS_WHEN": "The default progress bar showing mode, see term.progress.when", + "CARGO_TERM_PROGRESS_WIDTH": "The default progress bar width, see term.progress.width", + "CARGO_TERM_QUIET": "Quiet mode, see term.quiet", + "CARGO_TERM_VERBOSE": "The default terminal verbosity, see term.verbose", + }, + VariableCompletion: map[string]carapace.Action{ + "CARGO_BUILD_DEP_INFO_BASEDIR": carapace.ActionDirectories(), + "CARGO_BUILD_INCREMENTAL": _bool, + "CARGO_BUILD_RUSTFLAGS": bridge.ActionCarapaceBin("rustc").Split(), + "CARGO_BUILD_RUSTDOCFLAGS": bridge.ActionCarapaceBin("rustdoc").Split(), + "CARGO_BUILD_TARGET_DIR": carapace.ActionDirectories(), + "CARGO_CARGO_NEW_VCS": carapace.ActionValues("git", "hg", "pijul", "fossil", "none"), + "CARGO_HOME": carapace.ActionDirectories(), + "CARGO_HTTP_CHECK_REVOKE": _bool, + "CARGO_HTTP_DEBUG": _bool, + "CARGO_HTTP_MULTIPLEXING": _bool, + "CARGO_HTTP_USER_AGENT": http.ActionUserAgents(), + "CARGO_INCREMENTAL": carapace.ActionStyledValuesDescribed( + "0", "force disabled,", style.Red, + "1", "force enabled", style.Green, + ), + "CARGO_LOG": carapace.ActionValues("debug", "info", "warn", "error", "trace").StyleF(style.ForLogLevel), + "CARGO_MANIFEST_DIR": carapace.ActionDirectories(), + "CARGO_NET_GIT_FETCH_WITH_CLI": _bool, + "CARGO_NET_OFFLINE": _bool, + "CARGO_TARGET_DIR": carapace.ActionDirectories(), + "CARGO_TERM_COLOR": carapace.ActionValues("auto", "always", "never").StyleF(style.ForKeyword), + "CARGO_TERM_QUIET": _bool, + "CARGO_TERM_VERBOSE": _bool, + // TODO more completions + }, + } } - } diff --git a/pkg/actions/env/common.go b/pkg/actions/env/common.go index 230af98368..8d6153ee39 100644 --- a/pkg/actions/env/common.go +++ b/pkg/actions/env/common.go @@ -8,22 +8,23 @@ import ( ) func init() { - knownVariables["common"] = variables{ - Variables: map[string]string{ - "BROWSER": "the browser to use", - "EDITOR": "the editor to use", - "HTTP_PROXY": "http proxy server", - "HTTPS_PROXY": "https proxy server", - "HTTP_TIMEOUT": "The HTTP timeout in seconds", - "PAGER": "the pager to use", - "PATH": "A list of directories to be searched when executing commands", - }, - VariableCompletion: map[string]carapace.Action{ - "BROWSER": bridge.ActionCarapaceBin().Split(), - "EDITOR": bridge.ActionCarapaceBin().Split(), - "PAGER": bridge.ActionCarapaceBin().Split(), - "PATH": carapace.ActionDirectories().List(string(_os.PathListSeparator)).NoSpace(), - }, + knownVariables["common"] = func() variables { + return variables{ + Variables: map[string]string{ + "BROWSER": "the browser to use", + "EDITOR": "the editor to use", + "HTTP_PROXY": "http proxy server", + "HTTPS_PROXY": "https proxy server", + "HTTP_TIMEOUT": "The HTTP timeout in seconds", + "PAGER": "the pager to use", + "PATH": "A list of directories to be searched when executing commands", + }, + VariableCompletion: map[string]carapace.Action{ + "BROWSER": bridge.ActionCarapaceBin().Split(), + "EDITOR": bridge.ActionCarapaceBin().Split(), + "PAGER": bridge.ActionCarapaceBin().Split(), + "PATH": carapace.ActionDirectories().List(string(_os.PathListSeparator)).NoSpace(), + }, + } } - } diff --git a/pkg/actions/env/common_unix.go b/pkg/actions/env/common_unix.go index 7970feabae..74b4f817d2 100644 --- a/pkg/actions/env/common_unix.go +++ b/pkg/actions/env/common_unix.go @@ -6,23 +6,24 @@ import ( ) func init() { - knownVariables["common_unix"] = variables{ - Variables: map[string]string{ - "USER": "The current logged in user", - "HOME": "The home directory of the current user", - "EDITOR": "The default file editor to be used", - "SHELL": "The path of the current user’s shell, such as bash or zsh", - "LOGNAME": "The name of the current user", - "LANG": "The current locales settings", - "TERM": "The current terminal emulation", - "MAIL": "Location of where the current user’s mail is stored", - }, - VariableCompletion: map[string]carapace.Action{ - "HOME": carapace.ActionDirectories(), - "LANG": os.ActionLanguages(), - "LOGNAME": os.ActionUsers(), - "USER": os.ActionUsers(), - }, + knownVariables["common_unix"] = func() variables { + return variables{ + Variables: map[string]string{ + "USER": "The current logged in user", + "HOME": "The home directory of the current user", + "EDITOR": "The default file editor to be used", + "SHELL": "The path of the current user’s shell, such as bash or zsh", + "LOGNAME": "The name of the current user", + "LANG": "The current locales settings", + "TERM": "The current terminal emulation", + "MAIL": "Location of where the current user’s mail is stored", + }, + VariableCompletion: map[string]carapace.Action{ + "HOME": carapace.ActionDirectories(), + "LANG": os.ActionLanguages(), + "LOGNAME": os.ActionUsers(), + "USER": os.ActionUsers(), + }, + } } - } diff --git a/pkg/actions/env/docker.go b/pkg/actions/env/docker.go index e1bb578e47..1866430f4a 100644 --- a/pkg/actions/env/docker.go +++ b/pkg/actions/env/docker.go @@ -8,35 +8,36 @@ import ( ) func init() { - knownVariables["docker"] = variables{ - Condition: conditions.ConditionPath("docker"), - Variables: map[string]string{ - "DOCKER_API_VERSION": "Override the negotiated API version to use for debugging", - "DOCKER_CERT_PATH": "Location of your authentication keys", - "DOCKER_CONFIG": "The location of your client configuration files", - "DOCKER_CONTENT_TRUST_SERVER": "The URL of the Notary server to use", - "DOCKER_CONTENT_TRUST": "When set Docker uses notary to sign and verify images", - "DOCKER_CONTEXT": "Name of the docker context to use", - "DOCKER_DEFAULT_PLATFORM": "Default platform for commands that take the --platform flag", - "DOCKER_HIDE_LEGACY_COMMANDS": "When set, Docker hides \"legacy\" top-level commands", - "DOCKER_HOST": "Daemon socket to connect to", - "DOCKER_TLS_VERIFY": "When set Docker uses TLS and verifies the remote", - "BUILDKIT_PROGRESS": "Set type of progress output", - }, - VariableCompletion: map[string]carapace.Action{ - "DOCKER_API_VERSION": carapace.ActionValues(), - "DOCKER_CERT_PATH": carapace.ActionDirectories(), - "DOCKER_CONFIG": carapace.ActionFiles(), - "DOCKER_CONTENT_TRUST": carapace.ActionValues("1"), - "DOCKER_CONTEXT": docker.ActionContexts(), - "DOCKER_DEFAULT_PLATFORM": carapace.ActionValues(), // TODO - "DOCKER_HIDE_LEGACY_COMMANDS": carapace.ActionStyledValuesDescribed( - "0", "show", style.Carapace.KeywordNegative, - "1", "hide", style.Carapace.KeywordPositive, - ), - "DOCKER_TLS_VERIFY": carapace.ActionValues("1"), - "BUILDKIT_PROGRESS": carapace.ActionValues("auto", "plain", "tty"), - }, + knownVariables["docker"] = func() variables { + return variables{ + Condition: conditions.ConditionPath("docker"), + Variables: map[string]string{ + "DOCKER_API_VERSION": "Override the negotiated API version to use for debugging", + "DOCKER_CERT_PATH": "Location of your authentication keys", + "DOCKER_CONFIG": "The location of your client configuration files", + "DOCKER_CONTENT_TRUST_SERVER": "The URL of the Notary server to use", + "DOCKER_CONTENT_TRUST": "When set Docker uses notary to sign and verify images", + "DOCKER_CONTEXT": "Name of the docker context to use", + "DOCKER_DEFAULT_PLATFORM": "Default platform for commands that take the --platform flag", + "DOCKER_HIDE_LEGACY_COMMANDS": "When set, Docker hides \"legacy\" top-level commands", + "DOCKER_HOST": "Daemon socket to connect to", + "DOCKER_TLS_VERIFY": "When set Docker uses TLS and verifies the remote", + "BUILDKIT_PROGRESS": "Set type of progress output", + }, + VariableCompletion: map[string]carapace.Action{ + "DOCKER_API_VERSION": carapace.ActionValues(), + "DOCKER_CERT_PATH": carapace.ActionDirectories(), + "DOCKER_CONFIG": carapace.ActionFiles(), + "DOCKER_CONTENT_TRUST": carapace.ActionValues("1"), + "DOCKER_CONTEXT": docker.ActionContexts(), + "DOCKER_DEFAULT_PLATFORM": carapace.ActionValues(), // TODO + "DOCKER_HIDE_LEGACY_COMMANDS": carapace.ActionStyledValuesDescribed( + "0", "show", style.Carapace.KeywordNegative, + "1", "hide", style.Carapace.KeywordPositive, + ), + "DOCKER_TLS_VERIFY": carapace.ActionValues("1"), + "BUILDKIT_PROGRESS": carapace.ActionValues("auto", "plain", "tty"), + }, + } } - } diff --git a/pkg/actions/env/env.go b/pkg/actions/env/env.go index e81aaa2109..9594bb5894 100644 --- a/pkg/actions/env/env.go +++ b/pkg/actions/env/env.go @@ -13,6 +13,18 @@ import ( "gopkg.in/yaml.v3" ) +type variablesMap map[string]func() variables + +func (m variablesMap) get() map[string]variables { + result := make(map[string]variables) + for k, v := range m { + result[k] = v() // TODO this should only be done once no matter how often get() is called + } + return result +} + +var knownVariables = make(variablesMap) + type variables struct { Condition condition.Condition Variables map[string]string @@ -51,8 +63,6 @@ func (v *variables) UnmarshalYAML(unmarshal func(interface{}) error) error { return nil } -var knownVariables = map[string]variables{} - // ActionKnownEnvironmentVariables completes known environment variables // // GOARCH (The architecture, or processor, for which to compile code) @@ -67,7 +77,7 @@ func ActionKnownEnvironmentVariables() carapace.Action { func actionKnownEnvironmentVariables() carapace.Action { return carapace.ActionCallback(func(c carapace.Context) carapace.Action { vals := make([]string, 0) - for _, v := range knownVariables { + for _, v := range knownVariables.get() { if v.Condition != nil && !v.Condition(c) { continue } @@ -114,7 +124,7 @@ func ActionEnvironmentVariableValues(s string) carapace.Action { } } - for _, v := range knownVariables { + for _, v := range knownVariables.get() { if action, ok := v.VariableCompletion[s]; ok { found = true return carapace.Batch( diff --git a/pkg/actions/env/env_test.go b/pkg/actions/env/env_test.go index 5203523e06..d3fe6f8b66 100644 --- a/pkg/actions/env/env_test.go +++ b/pkg/actions/env/env_test.go @@ -3,7 +3,7 @@ package env import "testing" func TestKnownVariables(t *testing.T) { - for k, v := range knownVariables { + for k, v := range knownVariables.get() { for name := range v.VariableCompletion { if _, ok := v.Variables[name]; !ok { t.Errorf("variables %#v is unknown in %#v", name, k) diff --git a/pkg/actions/env/gh.go b/pkg/actions/env/gh.go index b42b9e2bc3..3ed3cfd6c8 100644 --- a/pkg/actions/env/gh.go +++ b/pkg/actions/env/gh.go @@ -8,33 +8,35 @@ import ( ) func init() { - knownVariables["gh"] = variables{ - Condition: conditions.ConditionPath("gh"), - Variables: map[string]string{ - "GH_TOKEN": "an authentication token for github.com API requests", - "GH_ENTERPRISE_TOKEN": "an authentication token for API requests to GitHub Enterprise", - "GH_HOST": "specify the GitHub hostname", - "GH_REPO": "specify the GitHub repository", - "GH_EDITOR": "the editor tool to use for authoring text", - "GH_BROWSER": "the web browser to use for opening links", - "GH_DEBUG": "set to a truthy value to enable verbose output on standard error", - "GH_PAGER": "a terminal paging program to send standard output", - "GH_FORCE_TTY": "set to any value to force terminal-style output", - "GH_NO_UPDATE_NOTIFIER": "set to any value to disable update notifications", - "GH_CONFIG_DIR": "the directory where gh will store configuration files", - "GH_PROMPT_DISABLED": "set to any value to disable interactive prompting in the terminal", - "GH_PATH": "set the path to the gh executable", - }, - VariableCompletion: map[string]carapace.Action{ - "GH_REPO": gh.ActionOwnerRepositories(gh.HostOpts{}), - "GH_EDITOR": bridge.ActionCarapaceBin().Split(), - "GH_BROWSER": bridge.ActionCarapaceBin().Split(), - "GH_DEBUG": carapace.ActionValues("1"), - "GH_PAGER": bridge.ActionCarapaceBin().Split(), - "GH_FORCE_TTY": carapace.ActionValues("1"), - "GH_NO_UPDATE_NOTIFIER": carapace.ActionValues("1"), - "GH_CONFIG_DIR": carapace.ActionDirectories(), - "GH_PATH": carapace.ActionFiles(), - }, + knownVariables["gh"] = func() variables { + return variables{ + Condition: conditions.ConditionPath("gh"), + Variables: map[string]string{ + "GH_TOKEN": "an authentication token for github.com API requests", + "GH_ENTERPRISE_TOKEN": "an authentication token for API requests to GitHub Enterprise", + "GH_HOST": "specify the GitHub hostname", + "GH_REPO": "specify the GitHub repository", + "GH_EDITOR": "the editor tool to use for authoring text", + "GH_BROWSER": "the web browser to use for opening links", + "GH_DEBUG": "set to a truthy value to enable verbose output on standard error", + "GH_PAGER": "a terminal paging program to send standard output", + "GH_FORCE_TTY": "set to any value to force terminal-style output", + "GH_NO_UPDATE_NOTIFIER": "set to any value to disable update notifications", + "GH_CONFIG_DIR": "the directory where gh will store configuration files", + "GH_PROMPT_DISABLED": "set to any value to disable interactive prompting in the terminal", + "GH_PATH": "set the path to the gh executable", + }, + VariableCompletion: map[string]carapace.Action{ + "GH_REPO": gh.ActionOwnerRepositories(gh.HostOpts{}), + "GH_EDITOR": bridge.ActionCarapaceBin().Split(), + "GH_BROWSER": bridge.ActionCarapaceBin().Split(), + "GH_DEBUG": carapace.ActionValues("1"), + "GH_PAGER": bridge.ActionCarapaceBin().Split(), + "GH_FORCE_TTY": carapace.ActionValues("1"), + "GH_NO_UPDATE_NOTIFIER": carapace.ActionValues("1"), + "GH_CONFIG_DIR": carapace.ActionDirectories(), + "GH_PATH": carapace.ActionFiles(), + }, + } } } diff --git a/pkg/actions/env/git.go b/pkg/actions/env/git.go index 29cd7c1168..edb16e7f2a 100644 --- a/pkg/actions/env/git.go +++ b/pkg/actions/env/git.go @@ -11,75 +11,77 @@ import ( ) func init() { - _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) - knownVariables["git"] = variables{ - Condition: conditions.ConditionPath("git"), - Variables: map[string]string{ - "GIT_ALTERNATE_OBJECT_DIRECTORIES": "is a colon-separated list which tells Git where to check for objects", - "GIT_ASKPASS": "is an override for the core.askpass configuration value", - "GIT_AUTHOR_DATE": "is the timestamp used for the “author” field", - "GIT_AUTHOR_EMAIL": "is the email for the “author” field", - "GIT_AUTHOR_NAME": "is the human-readable name in the “author” field", - "GIT_CEILING_DIRECTORIES": "controls the behavior of searching for a .git directory", - "GIT_COMMITTER_DATE": "is used for the timestamp in the “committer” field", - "GIT_COMMITTER_EMAIL": "is the email address for the “committer” field", - "GIT_COMMITTER_NAME": "sets the human name for the “committer” field", - "GIT_CONFIG_NOSYSTEM": "if set, disables the use of the system-wide configuration file", - "GIT_DIFF_OPTS": "controls the number of context lines shown in a git diff command", - "GIT_DIFF_PATH_COUNTER": "represents which file in a series is being diffed (starting with 1)", - "GIT_DIFF_PATH_TOTAL": "total number of files in the batch", - "GIT_DIR": "is the location of the .git folder", - "GIT_EDITOR": "is the editor Git will launch when the user needs to edit some text", - "GIT_EXEC_PATH": "determines where Git looks for its sub-programs", - "GIT_EXTERNAL_DIFF": "is used as an override for the diff.external configuration value", - "GIT_FLUSH": "can be used to force Git to use non-buffered I/O when writing incrementally to stdout", - "GIT_GLOB_PATHSPECS": "controls the default behavior of wildcards in pathspecs", - "GIT_HTTP_USER_AGENT": "sets the user-agent string used by Git when communicating over HTTP", - "GIT_ICASE_PATHSPECS": "sets all pathspecs to work in a case-insensitive manner", - "GIT_INDEX_FILE": "is the path to the index file (non-bare repositories only)", - "GIT_LITERAL_PATHSPECS": "disables both of the above behaviors", - "GIT_MERGE_VERBOSITY": "controls the output for the recursive merge strategy", - "GIT_NAMESPACE": "controls access to namespaced refs", - "GIT_NOGLOB_PATHSPECS": "controls the default behavior of wildcards in pathspecs", - "GIT_OBJECT_DIRECTORY": "can be used to specify the location of the directory that usually resides at .git/objects", - "GIT_PAGER": "controls the program used to display multi-page output on the command line", - "GIT_REFLOG_ACTION": "lets you specify the descriptive text written to the reflog", - "GIT_SSH": "a program that is invoked instead of ssh when Git tries to connect to an SSH host", - "GIT_SSH_COMMAND": "sets the SSH command used when Git tries to connect to an SSH host", - "GIT_SSL_NO_VERIFY": "tells Git not to verify SSL certificates", - "GIT_TRACE": "controls general traces, which don’t fit into any specific category", - "GIT_TRACE_PACK_ACCESS": "controls tracing of packfile access", - "GIT_TRACE_PACKET": "enables packet-level tracing for network operations", - "GIT_TRACE_PERFORMANCE": "controls logging of performance data", - "GIT_TRACE_SETUP": "shows information about what Git is discovering about the repository and environment it’s interacting with", - "GIT_WORK_TREE": "is the location of the root of the working directory for a non-bare repository", - }, - VariableCompletion: map[string]carapace.Action{ - // TODO complete more variables - "GIT_ALTERNATE_OBJECT_DIRECTORIES": carapace.ActionDirectories().MultiParts(":"), - "GIT_ASKPASS": git.ActionConfigValues("core.askpass"), - "GIT_CEILING_DIRECTORIES": carapace.ActionDirectories().MultiParts("").NoSpace(), - "GIT_COMMITTER_DATE": time.ActionDate(), - "GIT_CONFIG_NOSYSTEM": _bool, - "GIT_DIR": carapace.ActionDirectories(), - "GIT_EXTERNAL_DIFF": git.ActionConfigValues("diff.external"), - "GIT_DIFF_OPTS": carapace.ActionCallback(func(c carapace.Context) carapace.Action { - cmd := &cobra.Command{} - carapace.Gen(cmd).Standalone() - cmd.Flags().StringP("unified", "U", "", "Generate diffs with lines of context instead of the usual three") - return carapace.ActionExecute(cmd) - }).Split(), - "GIT_EDITOR": git.ActionConfigValues("core.editor"), - "GIT_EXEC_PATH": carapace.ActionDirectories(), - "GIT_FLUSH": carapace.ActionValuesDescribed( - "0", "buffer all output", - "1", "flush more often", - ), - "GIT_HTTP_USER_AGENT": http.ActionUserAgents(), - "GIT_INDEX_FILE": carapace.ActionFiles(), - "GIT_OBJECT_DIRECTORY": carapace.ActionDirectories(), - "GIT_PAGER": git.ActionConfigValues("core.pager"), - "GIT_WORK_TREE": carapace.ActionDirectories(), - }, + knownVariables["git"] = func() variables { + _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) + return variables{ + Condition: conditions.ConditionPath("git"), + Variables: map[string]string{ + "GIT_ALTERNATE_OBJECT_DIRECTORIES": "is a colon-separated list which tells Git where to check for objects", + "GIT_ASKPASS": "is an override for the core.askpass configuration value", + "GIT_AUTHOR_DATE": "is the timestamp used for the “author” field", + "GIT_AUTHOR_EMAIL": "is the email for the “author” field", + "GIT_AUTHOR_NAME": "is the human-readable name in the “author” field", + "GIT_CEILING_DIRECTORIES": "controls the behavior of searching for a .git directory", + "GIT_COMMITTER_DATE": "is used for the timestamp in the “committer” field", + "GIT_COMMITTER_EMAIL": "is the email address for the “committer” field", + "GIT_COMMITTER_NAME": "sets the human name for the “committer” field", + "GIT_CONFIG_NOSYSTEM": "if set, disables the use of the system-wide configuration file", + "GIT_DIFF_OPTS": "controls the number of context lines shown in a git diff command", + "GIT_DIFF_PATH_COUNTER": "represents which file in a series is being diffed (starting with 1)", + "GIT_DIFF_PATH_TOTAL": "total number of files in the batch", + "GIT_DIR": "is the location of the .git folder", + "GIT_EDITOR": "is the editor Git will launch when the user needs to edit some text", + "GIT_EXEC_PATH": "determines where Git looks for its sub-programs", + "GIT_EXTERNAL_DIFF": "is used as an override for the diff.external configuration value", + "GIT_FLUSH": "can be used to force Git to use non-buffered I/O when writing incrementally to stdout", + "GIT_GLOB_PATHSPECS": "controls the default behavior of wildcards in pathspecs", + "GIT_HTTP_USER_AGENT": "sets the user-agent string used by Git when communicating over HTTP", + "GIT_ICASE_PATHSPECS": "sets all pathspecs to work in a case-insensitive manner", + "GIT_INDEX_FILE": "is the path to the index file (non-bare repositories only)", + "GIT_LITERAL_PATHSPECS": "disables both of the above behaviors", + "GIT_MERGE_VERBOSITY": "controls the output for the recursive merge strategy", + "GIT_NAMESPACE": "controls access to namespaced refs", + "GIT_NOGLOB_PATHSPECS": "controls the default behavior of wildcards in pathspecs", + "GIT_OBJECT_DIRECTORY": "can be used to specify the location of the directory that usually resides at .git/objects", + "GIT_PAGER": "controls the program used to display multi-page output on the command line", + "GIT_REFLOG_ACTION": "lets you specify the descriptive text written to the reflog", + "GIT_SSH": "a program that is invoked instead of ssh when Git tries to connect to an SSH host", + "GIT_SSH_COMMAND": "sets the SSH command used when Git tries to connect to an SSH host", + "GIT_SSL_NO_VERIFY": "tells Git not to verify SSL certificates", + "GIT_TRACE": "controls general traces, which don’t fit into any specific category", + "GIT_TRACE_PACK_ACCESS": "controls tracing of packfile access", + "GIT_TRACE_PACKET": "enables packet-level tracing for network operations", + "GIT_TRACE_PERFORMANCE": "controls logging of performance data", + "GIT_TRACE_SETUP": "shows information about what Git is discovering about the repository and environment it’s interacting with", + "GIT_WORK_TREE": "is the location of the root of the working directory for a non-bare repository", + }, + VariableCompletion: map[string]carapace.Action{ + // TODO complete more variables + "GIT_ALTERNATE_OBJECT_DIRECTORIES": carapace.ActionDirectories().MultiParts(":"), + "GIT_ASKPASS": git.ActionConfigValues("core.askpass"), + "GIT_CEILING_DIRECTORIES": carapace.ActionDirectories().MultiParts("").NoSpace(), + "GIT_COMMITTER_DATE": time.ActionDate(), + "GIT_CONFIG_NOSYSTEM": _bool, + "GIT_DIR": carapace.ActionDirectories(), + "GIT_EXTERNAL_DIFF": git.ActionConfigValues("diff.external"), + "GIT_DIFF_OPTS": carapace.ActionCallback(func(c carapace.Context) carapace.Action { + cmd := &cobra.Command{} + carapace.Gen(cmd).Standalone() + cmd.Flags().StringP("unified", "U", "", "Generate diffs with lines of context instead of the usual three") + return carapace.ActionExecute(cmd) + }).Split(), + "GIT_EDITOR": git.ActionConfigValues("core.editor"), + "GIT_EXEC_PATH": carapace.ActionDirectories(), + "GIT_FLUSH": carapace.ActionValuesDescribed( + "0", "buffer all output", + "1", "flush more often", + ), + "GIT_HTTP_USER_AGENT": http.ActionUserAgents(), + "GIT_INDEX_FILE": carapace.ActionFiles(), + "GIT_OBJECT_DIRECTORY": carapace.ActionDirectories(), + "GIT_PAGER": git.ActionConfigValues("core.pager"), + "GIT_WORK_TREE": carapace.ActionDirectories(), + }, + } } } diff --git a/pkg/actions/env/golang.go b/pkg/actions/env/golang.go index 154b71cd53..dc81b21087 100644 --- a/pkg/actions/env/golang.go +++ b/pkg/actions/env/golang.go @@ -9,123 +9,124 @@ import ( ) func init() { - knownVariables["golang"] = variables{ - Condition: conditions.ConditionPath("go"), - Variables: map[string]string{ - "AR": "The command to use to manipulate library archives when building with the gccgo compiler", - "CC": "The command to use to compile C code", - "CGO_CFFLAGS_ALLOW": "Like CGO_CFLAGS_ALLOW but for the Fortran compiler", - "CGO_CFFLAGS_DISALLOW": "Like CGO_CFLAGS_DISALLOW but for the Fortran compiler", - "CGO_CFFLAGS": "Like CGO_CFLAGS but for the Fortran compiler", - "CGO_CFLAGS_ALLOW": "A regular expression specifying additional flags to allow to appear in #cgo CFLAGS source code directives", - "CGO_CFLAGS_DISALLOW": "A regular expression specifying flags that must be disallowed from appearing in #cgo CFLAGS source code directives", - "CGO_CFLAGS": "Flags that cgo will pass to the compiler when compiling C code", - "CGO_CPPFLAGS_ALLOW": "Like CGO_CFLAGS_ALLOW but for the C preprocessor", - "CGO_CPPFLAGS_DISALLOW": "Like CGO_CFLAGS_DISALLOW but for the C preprocessor", - "CGO_CPPFLAGS": "Like CGO_CFLAGS but for the C preprocessor", - "CGO_CXXFLAGS_ALLOW": "Like CGO_CFLAGS_ALLOW but for the C++ compiler", - "CGO_CXXFLAGS_DISALLOW": "Like CGO_CFLAGS_DISALLOW but for the C++ compiler", - "CGO_CXXFLAGS": "Like CGO_CFLAGS but for the C++ compiler", - "CGO_ENABLED": "Whether the cgo command is supported", - "CGO_LDFLAGS_ALLOW": "Like CGO_CFLAGS_ALLOW but for the linker", - "CGO_LDFLAGS_DISALLOW": "Like CGO_CFLAGS_DISALLOW but for the linker", - "CGO_LDFLAGS": "Like CGO_CFLAGS but for the linker", - "CXX": "The command to use to compile C++ code", - "FC": "The command to use to compile Fortran code", - "GCCGO": "The gccgo command to run for 'go build -compiler=gccgo'", - "GCCGOTOOLDIR": "If set, where to find gccgo tools, such as cgo", - "GO111MODULE": "Controls whether the go command runs in module-aware mode or GOPATH mode", - "GO386": "For GOARCH=386, how to implement floating point instructions", - "GOAMD64": "For GOARCH=amd64, the microarchitecture level for which to compile", - "GOARCH": "The architecture, or processor, for which to compile code", - "GOARM": "For GOARCH=arm, the ARM architecture for which to compile", - "GOBIN": "The directory where 'go install' will install a command", - "GOCACHE": "The directory where the go command will store cached information for reuse in future builds", - "GOCOVERDIR": "Directory into which to write code coverage data", - "GODEBUG": "Enable various debugging facilities", - "GOENV": "The location of the Go environment configuration file", - "GOEXE": "The executable file name suffix (\".exe\" on Windows, \"\" on other systems)", - "GOEXPERIMENT": "Comma-separated list of toolchain experiments to enable or disable", - "GO_EXTLINK_ENABLED": "Whether the linker should use external linking mode", - "GOFLAGS": "A space-separated list of -flag=value settings to apply to go commands by default", - "GOGCCFLAGS": "A space-separated list of arguments supplied to the CC command", - "GOHOSTARCH": "The architecture (GOARCH) of the Go toolchain binaries", - "GOHOSTOS": "The operating system (GOOS) of the Go toolchain binaries", - "GOINSECURE": "Comma-separated list of glob patterns", - "GOMIPS64": "For GOARCH=mips64{,le}, whether to use floating point instructions", - "GOMIPS": "For GOARCH=mips{,le}, whether to use floating point instructions", - "GOMODCACHE": "The directory where the go command will store downloaded modules", - "GOMOD": "The absolute path to the go.mod of the main module", - "GONOPROXY": "Comma-separated list of glob patterns", - "GONOSUMDB": "Comma-separated list of glob patterns", - "GOOS": "The operating system for which to compile code", - "GOPATH": "Controls where various files are stored", - "GOPPC64": "For GOARCH=ppc64{,le}, the target ISA (Instruction Set Architecture)", - "GOPRIVATE": "Comma-separated list of glob patterns", - "GOPROXY": "URL of Go module proxy", - "GOROOT_FINAL": "The root of the installed Go tree, when it is installed in a location other than where it is built", - "GOROOT": "The root of the go tree", - "GOSUMDB": "The name of checksum database to use and optionally its public key and URL", - "GOTMPDIR": "The directory where the go command will write temporary source files, packages, and binaries", - "GOTOOLCHAIN": "Controls which Go toolchain is used", - "GOTOOLDIR": "The directory where the go tools (compile, cover, doc, etc...) are installed", - "GOVCS": "Lists version control commands that may be used with matching servers", - "GOVERSION": "The version of the installed Go tree, as reported by runtime.Version", - "GOWASM": "For GOARCH=wasm, comma-separated list of experimental WebAssembly features to use", - "GOWORK": "In module aware mode, use the given go.work file as a workspace file", - "PKG_CONFIG": "Path to pkg-config tool", - }, - VariableCompletion: map[string]carapace.Action{ - // TODO more flags - "AR": bridge.ActionCarapaceBin().Split(), - "CC": bridge.ActionCarapaceBin().Split(), - "CGO_ENABLED": carapace.ActionStyledValuesDescribed( - "0", "disabled", style.Carapace.KeywordNegative, - "1", "enabled", style.Carapace.KeywordPositive, - ), - "CXX": bridge.ActionCarapaceBin().Split(), - "FC": bridge.ActionCarapaceBin().Split(), - "GCCGO": bridge.ActionCarapaceBin().Split(), - "GCCGOTOOLDIR": carapace.ActionDirectories(), - "GO111MODULE": carapace.ActionValues("off", "on", "auto").StyleF(style.ForKeyword), - "GOARCH": golang.ActionArchitectures(), - "GOBIN": carapace.ActionDirectories(), - "GOCACHE": carapace.ActionDirectories(), - "GOENV": carapace.Batch( - carapace.ActionFiles(), - carapace.ActionValues("off").StyleF(style.ForKeyword), - ).ToA(), - "GOFLAGS": bridge.ActionCarapaceBin("go").Split(), // not entirely correct as it includes the subcommand but still helpful as that can be removed afterwards - "GOMODCACHE": carapace.ActionDirectories(), - "GOOS": golang.ActionOperatingSystems(), - "GOTMPDIR": carapace.ActionDirectories(), - "GOTOOLCHAIN": carapace.ActionMultiPartsN("+", 2, func(c carapace.Context) carapace.Action { - switch len(c.Parts) { - case 0: - return golang.ActionVersions().Prefix("go") - default: - return carapace.ActionValues("auto").StyleF(style.ForKeyword) - } - }), - "GOVCS": carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action { - switch len(c.Parts) { - case 0: - return carapace.ActionValues("public", "private").StyleF(style.ForKeyword).Suffix(":") - default: - return carapace.ActionValuesDescribed( - "all", "", - "bzr", "Bazaar", - "fossil", "Fossil", - "git", "Git", - "hg", "Mercurial", - "off", "", - "svn", "Subversion", - ).StyleF(style.ForKeyword).UniqueList("|") - } - }).List(","), - "GOWORK": carapace.ActionFiles(), - "PKG_CONFIG": carapace.ActionFiles(), - }, + knownVariables["golang"] = func() variables { + return variables{ + Condition: conditions.ConditionPath("go"), + Variables: map[string]string{ + "AR": "The command to use to manipulate library archives when building with the gccgo compiler", + "CC": "The command to use to compile C code", + "CGO_CFFLAGS_ALLOW": "Like CGO_CFLAGS_ALLOW but for the Fortran compiler", + "CGO_CFFLAGS_DISALLOW": "Like CGO_CFLAGS_DISALLOW but for the Fortran compiler", + "CGO_CFFLAGS": "Like CGO_CFLAGS but for the Fortran compiler", + "CGO_CFLAGS_ALLOW": "A regular expression specifying additional flags to allow to appear in #cgo CFLAGS source code directives", + "CGO_CFLAGS_DISALLOW": "A regular expression specifying flags that must be disallowed from appearing in #cgo CFLAGS source code directives", + "CGO_CFLAGS": "Flags that cgo will pass to the compiler when compiling C code", + "CGO_CPPFLAGS_ALLOW": "Like CGO_CFLAGS_ALLOW but for the C preprocessor", + "CGO_CPPFLAGS_DISALLOW": "Like CGO_CFLAGS_DISALLOW but for the C preprocessor", + "CGO_CPPFLAGS": "Like CGO_CFLAGS but for the C preprocessor", + "CGO_CXXFLAGS_ALLOW": "Like CGO_CFLAGS_ALLOW but for the C++ compiler", + "CGO_CXXFLAGS_DISALLOW": "Like CGO_CFLAGS_DISALLOW but for the C++ compiler", + "CGO_CXXFLAGS": "Like CGO_CFLAGS but for the C++ compiler", + "CGO_ENABLED": "Whether the cgo command is supported", + "CGO_LDFLAGS_ALLOW": "Like CGO_CFLAGS_ALLOW but for the linker", + "CGO_LDFLAGS_DISALLOW": "Like CGO_CFLAGS_DISALLOW but for the linker", + "CGO_LDFLAGS": "Like CGO_CFLAGS but for the linker", + "CXX": "The command to use to compile C++ code", + "FC": "The command to use to compile Fortran code", + "GCCGO": "The gccgo command to run for 'go build -compiler=gccgo'", + "GCCGOTOOLDIR": "If set, where to find gccgo tools, such as cgo", + "GO111MODULE": "Controls whether the go command runs in module-aware mode or GOPATH mode", + "GO386": "For GOARCH=386, how to implement floating point instructions", + "GOAMD64": "For GOARCH=amd64, the microarchitecture level for which to compile", + "GOARCH": "The architecture, or processor, for which to compile code", + "GOARM": "For GOARCH=arm, the ARM architecture for which to compile", + "GOBIN": "The directory where 'go install' will install a command", + "GOCACHE": "The directory where the go command will store cached information for reuse in future builds", + "GOCOVERDIR": "Directory into which to write code coverage data", + "GODEBUG": "Enable various debugging facilities", + "GOENV": "The location of the Go environment configuration file", + "GOEXE": "The executable file name suffix (\".exe\" on Windows, \"\" on other systems)", + "GOEXPERIMENT": "Comma-separated list of toolchain experiments to enable or disable", + "GO_EXTLINK_ENABLED": "Whether the linker should use external linking mode", + "GOFLAGS": "A space-separated list of -flag=value settings to apply to go commands by default", + "GOGCCFLAGS": "A space-separated list of arguments supplied to the CC command", + "GOHOSTARCH": "The architecture (GOARCH) of the Go toolchain binaries", + "GOHOSTOS": "The operating system (GOOS) of the Go toolchain binaries", + "GOINSECURE": "Comma-separated list of glob patterns", + "GOMIPS64": "For GOARCH=mips64{,le}, whether to use floating point instructions", + "GOMIPS": "For GOARCH=mips{,le}, whether to use floating point instructions", + "GOMODCACHE": "The directory where the go command will store downloaded modules", + "GOMOD": "The absolute path to the go.mod of the main module", + "GONOPROXY": "Comma-separated list of glob patterns", + "GONOSUMDB": "Comma-separated list of glob patterns", + "GOOS": "The operating system for which to compile code", + "GOPATH": "Controls where various files are stored", + "GOPPC64": "For GOARCH=ppc64{,le}, the target ISA (Instruction Set Architecture)", + "GOPRIVATE": "Comma-separated list of glob patterns", + "GOPROXY": "URL of Go module proxy", + "GOROOT_FINAL": "The root of the installed Go tree, when it is installed in a location other than where it is built", + "GOROOT": "The root of the go tree", + "GOSUMDB": "The name of checksum database to use and optionally its public key and URL", + "GOTMPDIR": "The directory where the go command will write temporary source files, packages, and binaries", + "GOTOOLCHAIN": "Controls which Go toolchain is used", + "GOTOOLDIR": "The directory where the go tools (compile, cover, doc, etc...) are installed", + "GOVCS": "Lists version control commands that may be used with matching servers", + "GOVERSION": "The version of the installed Go tree, as reported by runtime.Version", + "GOWASM": "For GOARCH=wasm, comma-separated list of experimental WebAssembly features to use", + "GOWORK": "In module aware mode, use the given go.work file as a workspace file", + "PKG_CONFIG": "Path to pkg-config tool", + }, + VariableCompletion: map[string]carapace.Action{ + // TODO more flags + "AR": bridge.ActionCarapaceBin().Split(), + "CC": bridge.ActionCarapaceBin().Split(), + "CGO_ENABLED": carapace.ActionStyledValuesDescribed( + "0", "disabled", style.Carapace.KeywordNegative, + "1", "enabled", style.Carapace.KeywordPositive, + ), + "CXX": bridge.ActionCarapaceBin().Split(), + "FC": bridge.ActionCarapaceBin().Split(), + "GCCGO": bridge.ActionCarapaceBin().Split(), + "GCCGOTOOLDIR": carapace.ActionDirectories(), + "GO111MODULE": carapace.ActionValues("off", "on", "auto").StyleF(style.ForKeyword), + "GOARCH": golang.ActionArchitectures(), + "GOBIN": carapace.ActionDirectories(), + "GOCACHE": carapace.ActionDirectories(), + "GOENV": carapace.Batch( + carapace.ActionFiles(), + carapace.ActionValues("off").StyleF(style.ForKeyword), + ).ToA(), + "GOFLAGS": bridge.ActionCarapaceBin("go").Split(), // not entirely correct as it includes the subcommand but still helpful as that can be removed afterwards + "GOMODCACHE": carapace.ActionDirectories(), + "GOOS": golang.ActionOperatingSystems(), + "GOTMPDIR": carapace.ActionDirectories(), + "GOTOOLCHAIN": carapace.ActionMultiPartsN("+", 2, func(c carapace.Context) carapace.Action { + switch len(c.Parts) { + case 0: + return golang.ActionVersions().Prefix("go") + default: + return carapace.ActionValues("auto").StyleF(style.ForKeyword) + } + }), + "GOVCS": carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action { + switch len(c.Parts) { + case 0: + return carapace.ActionValues("public", "private").StyleF(style.ForKeyword).Suffix(":") + default: + return carapace.ActionValuesDescribed( + "all", "", + "bzr", "Bazaar", + "fossil", "Fossil", + "git", "Git", + "hg", "Mercurial", + "off", "", + "svn", "Subversion", + ).StyleF(style.ForKeyword).UniqueList("|") + } + }).List(","), + "GOWORK": carapace.ActionFiles(), + "PKG_CONFIG": carapace.ActionFiles(), + }, + } } - } diff --git a/pkg/actions/env/gradle.go b/pkg/actions/env/gradle.go index c82ddb22f3..f784b53ccf 100644 --- a/pkg/actions/env/gradle.go +++ b/pkg/actions/env/gradle.go @@ -7,18 +7,19 @@ import ( ) func init() { - knownVariables["gradle"] = variables{ - Condition: conditions.ConditionPath("gradle"), - Variables: map[string]string{ - "GRADLE_HOME": "Gradle distribution location", - "GRADLE_OPTS": "JVM arguments to use when starting the Gradle client VM", - "GRADLE_USER_HOME": "Gradle User Home directory (", - }, - VariableCompletion: map[string]carapace.Action{ - "GRADLE_HOME": carapace.ActionDirectories(), - "GRADLE_OPTS": bridge.ActionCarapaceBin("java").Split(), - "GRADLE_USER_HOME": carapace.ActionDirectories(), - }, + knownVariables["gradle"] = func() variables { + return variables{ + Condition: conditions.ConditionPath("gradle"), + Variables: map[string]string{ + "GRADLE_HOME": "Gradle distribution location", + "GRADLE_OPTS": "JVM arguments to use when starting the Gradle client VM", + "GRADLE_USER_HOME": "Gradle User Home directory (", + }, + VariableCompletion: map[string]carapace.Action{ + "GRADLE_HOME": carapace.ActionDirectories(), + "GRADLE_OPTS": bridge.ActionCarapaceBin("java").Split(), + "GRADLE_USER_HOME": carapace.ActionDirectories(), + }, + } } - } diff --git a/pkg/actions/env/java.go b/pkg/actions/env/java.go index dfb14889d3..d6becbea17 100644 --- a/pkg/actions/env/java.go +++ b/pkg/actions/env/java.go @@ -6,14 +6,15 @@ import ( ) func init() { - knownVariables["java"] = variables{ - Condition: conditions.ConditionPath("java"), - Variables: map[string]string{ - "JAVA_HOME": "JDK installation directory", - }, - VariableCompletion: map[string]carapace.Action{ - "JAVA_HOME": carapace.ActionDirectories(), - }, + knownVariables["java"] = func() variables { + return variables{ + Condition: conditions.ConditionPath("java"), + Variables: map[string]string{ + "JAVA_HOME": "JDK installation directory", + }, + VariableCompletion: map[string]carapace.Action{ + "JAVA_HOME": carapace.ActionDirectories(), + }, + } } - } diff --git a/pkg/actions/env/maven.go b/pkg/actions/env/maven.go index 93922b5dc2..c6841039f2 100644 --- a/pkg/actions/env/maven.go +++ b/pkg/actions/env/maven.go @@ -7,16 +7,17 @@ import ( ) func init() { - knownVariables["maven"] = variables{ - Condition: conditions.ConditionPath("mvn"), - Variables: map[string]string{ - "MAVEN_OPTS": "parameters used to start up the JVM running Maven", - "MAVEN_ARGS": "arguments passed to Maven before CLI arguments", - }, - VariableCompletion: map[string]carapace.Action{ - "MAVEN_OPTS": bridge.ActionCarapaceBin("java").Split(), - "MAVEN_ARGS": bridge.ActionCarapaceBin("mvn").Split(), - }, + knownVariables["maven"] = func() variables { + return variables{ + Condition: conditions.ConditionPath("mvn"), + Variables: map[string]string{ + "MAVEN_OPTS": "parameters used to start up the JVM running Maven", + "MAVEN_ARGS": "arguments passed to Maven before CLI arguments", + }, + VariableCompletion: map[string]carapace.Action{ + "MAVEN_OPTS": bridge.ActionCarapaceBin("java").Split(), + "MAVEN_ARGS": bridge.ActionCarapaceBin("mvn").Split(), + }, + } } - } diff --git a/pkg/actions/env/nocolor.go b/pkg/actions/env/nocolor.go index f6fa3c2042..c092cbfe19 100644 --- a/pkg/actions/env/nocolor.go +++ b/pkg/actions/env/nocolor.go @@ -6,16 +6,17 @@ import ( ) func init() { - knownVariables["nocolor"] = variables{ - Variables: map[string]string{ - "NO_COLOR": "disable colors in supported commands", - }, - VariableCompletion: map[string]carapace.Action{ - "NO_COLOR": carapace.ActionStyledValuesDescribed( - "0", "show colors", style.Carapace.KeywordNegative, - "1", "do not show colors", style.Carapace.KeywordPositive, - ), - }, + knownVariables["nocolor"] = func() variables { + return variables{ + Variables: map[string]string{ + "NO_COLOR": "disable colors in supported commands", + }, + VariableCompletion: map[string]carapace.Action{ + "NO_COLOR": carapace.ActionStyledValuesDescribed( + "0", "show colors", style.Carapace.KeywordNegative, + "1", "do not show colors", style.Carapace.KeywordPositive, + ), + }, + } } - } diff --git a/pkg/actions/env/node.go b/pkg/actions/env/node.go index 6b3e55f873..7f33a31a25 100644 --- a/pkg/actions/env/node.go +++ b/pkg/actions/env/node.go @@ -7,36 +7,37 @@ import ( ) func init() { - _bool := carapace.ActionValuesDescribed("0", "disabled", "1", "enabled").StyleF(style.ForKeyword) - knownVariables["node"] = variables{ - Condition: conditions.ConditionPath("node"), - Variables: map[string]string{ - "NODE_DEBUG": "Comma-separated list of core modules that should print debug information", - "NODE_DEBUG_NATIVE": "Comma-separated list of C++ core modules that should print debug information", - "NODE_DISABLE_COLORS": "When set to 1, colors will not be used in the REPL", - "NODE_EXTRA_CA_CERTS": "When set, the well-known “root” CAs will be extended with the extra certificates in file", - "NODE_ICU_DATA": "Data path for ICU (Intl object) data", - "NODE_NO_WARNINGS": "When set to 1, process warnings are silenced", - "NODE_OPTIONS": "A space-separated list of command-line options", - "NODE_PATH": "A colon-separated list of directories prefixed to the module search path", - "NODE_PENDING_DEPRECATION": "When set to 1, emit pending deprecation warnings", - "NODE_PRESERVE_SYMLINKS": "When set to 1, the module loader preserves symbolic links when resolving and caching modules", - "NODE_REDIRECT_WARNINGS": "Write process warnings to the given file instead of printing to stderr", - "NODE_REPL_HISTORY": "Path to the file used to store persistent REPL history", - "NODE_REPL_EXTERNAL_MODULE": "Path to a Node.js module which will be loaded in place of the built-in REPL", - "NODE_SKIP_PLATFORM_CHECK": "When set to 1, the check for a supported platform is skipped during Node.js startup", - "NODE_TLS_REJECT_UNAUTHORIZED": "When set to 0, TLS certificate validation is disabled", - "NODE_V8_COVERAGE": "When set, Node.js writes JavaScript code coverage information to dir", - }, - VariableCompletion: map[string]carapace.Action{ - // TODO more completions - "NODE_DISABLE_COLORS": _bool, - "NODE_NO_WARNINGS": _bool, - "NODE_PATH": carapace.ActionDirectories().List(":"), - "NODE_PENDING_DEPRECATION": _bool, - "NODE_SKIP_PLATFORM_CHECK": _bool, - "NODE_TLS_REJECT_UNAUTHORIZED": _bool, - }, + knownVariables["node"] = func() variables { + _bool := carapace.ActionValuesDescribed("0", "disabled", "1", "enabled").StyleF(style.ForKeyword) + return variables{ + Condition: conditions.ConditionPath("node"), + Variables: map[string]string{ + "NODE_DEBUG": "Comma-separated list of core modules that should print debug information", + "NODE_DEBUG_NATIVE": "Comma-separated list of C++ core modules that should print debug information", + "NODE_DISABLE_COLORS": "When set to 1, colors will not be used in the REPL", + "NODE_EXTRA_CA_CERTS": "When set, the well-known “root” CAs will be extended with the extra certificates in file", + "NODE_ICU_DATA": "Data path for ICU (Intl object) data", + "NODE_NO_WARNINGS": "When set to 1, process warnings are silenced", + "NODE_OPTIONS": "A space-separated list of command-line options", + "NODE_PATH": "A colon-separated list of directories prefixed to the module search path", + "NODE_PENDING_DEPRECATION": "When set to 1, emit pending deprecation warnings", + "NODE_PRESERVE_SYMLINKS": "When set to 1, the module loader preserves symbolic links when resolving and caching modules", + "NODE_REDIRECT_WARNINGS": "Write process warnings to the given file instead of printing to stderr", + "NODE_REPL_HISTORY": "Path to the file used to store persistent REPL history", + "NODE_REPL_EXTERNAL_MODULE": "Path to a Node.js module which will be loaded in place of the built-in REPL", + "NODE_SKIP_PLATFORM_CHECK": "When set to 1, the check for a supported platform is skipped during Node.js startup", + "NODE_TLS_REJECT_UNAUTHORIZED": "When set to 0, TLS certificate validation is disabled", + "NODE_V8_COVERAGE": "When set, Node.js writes JavaScript code coverage information to dir", + }, + VariableCompletion: map[string]carapace.Action{ + // TODO more completions + "NODE_DISABLE_COLORS": _bool, + "NODE_NO_WARNINGS": _bool, + "NODE_PATH": carapace.ActionDirectories().List(":"), + "NODE_PENDING_DEPRECATION": _bool, + "NODE_SKIP_PLATFORM_CHECK": _bool, + "NODE_TLS_REJECT_UNAUTHORIZED": _bool, + }, + } } - } diff --git a/pkg/actions/env/python.go b/pkg/actions/env/python.go index c1bf575ca1..808c2efb19 100644 --- a/pkg/actions/env/python.go +++ b/pkg/actions/env/python.go @@ -9,68 +9,70 @@ import ( ) func init() { - knownVariables["python"] = variables{ - Condition: conditions.ConditionPath("python"), - Variables: map[string]string{ - "PYTHONSAFEPATH": "prepend a potentially unsafe path to sys.path such as the current directory", - "PYTHONHOME": "Change the location of the standard Python libraries", - "PYTHONPATH": "Augments the default search path for module files", - "PYTHONPLATLIBDIR": "Override sys.platlibdir", - "PYTHONSTARTUP": "Python commands in this file are executed before the first prompt in interactive mode", - "PYTHONOPTIMIZE": "Remove assert statements and any code conditional on the value of __debug_", - "PYTHONDEBUG": "Turn on parser debugging output", - "PYTHONDONTWRITEBYTECODE": "Don't write .pyc files on import", - "PYTHONINSPECT": "enter interactive mode after executing the script or the command", - "PYTHONIOENCODING": "overrides the encoding used for stdin/stdout/stderr", - "PYTHONNOUSERSITE": "Don't add user site directory to sys.path", - "PYTHONUNBUFFERED": "Force the stdout and stderr streams to be unbuffered", - "PYTHONVERBOSE": "Print a message each time a module is initialized", - "PYTHONWARNINGS": "Warning control", - "PYTHONHASHSEED": "value used to seed the hashes of str and bytes objects", - "PYTHONINTMAXSTRDIGITS": "Limit the maximum digit characters in an int value when converting from a string", - "PYTHONMALLOC": "Set the Python memory allocators and/or install debug hooks", - "PYTHONMALLOCSTATS": "Python will print statistics of the pymalloc memory allocator", - "PYTHONASYNCIODEBUG": "enable the debug mode of the asyncio module", - "PYTHONTRACEMALLOC": "start tracing Python memory allocations using the tracemalloc module", - "PYTHONFAULTHANDLER": "call faulthandler.enable() at startup", - "PYTHONEXECUTABLE": "set sys.argv[0] to this value instead of the value got through the C runtime", - "PYTHONUSERBASE": "user base directory", - "PYTHONPROFILEIMPORTTIME": "show how long each import takes", - "PYTHONBREAKPOINT": "set debugger callable", - "PYTHONTHREADDEBUG": "print threading debug info", - "PYTHONDUMPREFS": "dump objects and reference counts still alive after shutting down the interpreter", - }, - VariableCompletion: map[string]carapace.Action{ - "PYTHONSAFEPATH": carapace.ActionDirectories(), - "PYTHONHOME": carapace.ActionDirectories(), - "PYTHONPATH": carapace.ActionDirectories().List(string(os.PathListSeparator)), - "PYTHONPLATLIBDIR": carapace.ActionDirectories(), - "PYTHONSTARTUP": carapace.ActionValues(), // TODO - "PYTHONOPTIMIZE": carapace.ActionValuesDescribed( - "1", "Remove assert statements and any code conditional on the value of __debug_", - "2", "Like '1' but also discard docstrings", - ), - "PYTHONDEBUG": carapace.ActionValues("1"), - "PYTHONDONTWRITEBYTECODE": carapace.ActionValues("1"), - "PYTHONINSPECT": carapace.ActionValues("1"), - "PYTHONIOENCODING": carapace.ActionValues(), // TODO - "PYTHONNOUSERSITE": carapace.ActionValues("1"), - "PYTHONUNBUFFERED": carapace.ActionValues("1"), - "PYTHONVERBOSE": carapace.ActionValues("1", "2"), - "PYTHONWARNINGS": python.ActionWarningControls().List(","), - "PYTHONHASHSEED": carapace.ActionValues(), - "PYTHONINTMAXSTRDIGITS": carapace.ActionValues(), - "PYTHONMALLOC": carapace.ActionValues("malloc", "pymalloc", "debug", "malloc_debug", "pymalloc_debug"), // TODO verify - "PYTHONMALLOCSTATS": carapace.ActionValues("1"), - "PYTHONASYNCIODEBUG": carapace.ActionValues("1"), - "PYTHONTRACEMALLOC": carapace.ActionValues("1", "5", "10", "25", "50", "100"), - "PYTHONFAULTHANDLER": carapace.ActionValues("1"), - "PYTHONEXECUTABLE": carapace.ActionValues(), - "PYTHONUSERBASE": carapace.ActionDirectories(), - "PYTHONPROFILEIMPORTTIME": carapace.ActionValues("1"), - "PYTHONBREAKPOINT": carapace.ActionValuesDescribed("0", "disable"), // TODO debuggers - "PYTHONTHREADDEBUG": carapace.ActionValues("1"), - "PYTHONDUMPREFS": carapace.ActionValues("1"), - }, + knownVariables["python"] = func() variables { + return variables{ + Condition: conditions.ConditionPath("python"), + Variables: map[string]string{ + "PYTHONSAFEPATH": "prepend a potentially unsafe path to sys.path such as the current directory", + "PYTHONHOME": "Change the location of the standard Python libraries", + "PYTHONPATH": "Augments the default search path for module files", + "PYTHONPLATLIBDIR": "Override sys.platlibdir", + "PYTHONSTARTUP": "Python commands in this file are executed before the first prompt in interactive mode", + "PYTHONOPTIMIZE": "Remove assert statements and any code conditional on the value of __debug_", + "PYTHONDEBUG": "Turn on parser debugging output", + "PYTHONDONTWRITEBYTECODE": "Don't write .pyc files on import", + "PYTHONINSPECT": "enter interactive mode after executing the script or the command", + "PYTHONIOENCODING": "overrides the encoding used for stdin/stdout/stderr", + "PYTHONNOUSERSITE": "Don't add user site directory to sys.path", + "PYTHONUNBUFFERED": "Force the stdout and stderr streams to be unbuffered", + "PYTHONVERBOSE": "Print a message each time a module is initialized", + "PYTHONWARNINGS": "Warning control", + "PYTHONHASHSEED": "value used to seed the hashes of str and bytes objects", + "PYTHONINTMAXSTRDIGITS": "Limit the maximum digit characters in an int value when converting from a string", + "PYTHONMALLOC": "Set the Python memory allocators and/or install debug hooks", + "PYTHONMALLOCSTATS": "Python will print statistics of the pymalloc memory allocator", + "PYTHONASYNCIODEBUG": "enable the debug mode of the asyncio module", + "PYTHONTRACEMALLOC": "start tracing Python memory allocations using the tracemalloc module", + "PYTHONFAULTHANDLER": "call faulthandler.enable() at startup", + "PYTHONEXECUTABLE": "set sys.argv[0] to this value instead of the value got through the C runtime", + "PYTHONUSERBASE": "user base directory", + "PYTHONPROFILEIMPORTTIME": "show how long each import takes", + "PYTHONBREAKPOINT": "set debugger callable", + "PYTHONTHREADDEBUG": "print threading debug info", + "PYTHONDUMPREFS": "dump objects and reference counts still alive after shutting down the interpreter", + }, + VariableCompletion: map[string]carapace.Action{ + "PYTHONSAFEPATH": carapace.ActionDirectories(), + "PYTHONHOME": carapace.ActionDirectories(), + "PYTHONPATH": carapace.ActionDirectories().List(string(os.PathListSeparator)), + "PYTHONPLATLIBDIR": carapace.ActionDirectories(), + "PYTHONSTARTUP": carapace.ActionValues(), // TODO + "PYTHONOPTIMIZE": carapace.ActionValuesDescribed( + "1", "Remove assert statements and any code conditional on the value of __debug_", + "2", "Like '1' but also discard docstrings", + ), + "PYTHONDEBUG": carapace.ActionValues("1"), + "PYTHONDONTWRITEBYTECODE": carapace.ActionValues("1"), + "PYTHONINSPECT": carapace.ActionValues("1"), + "PYTHONIOENCODING": carapace.ActionValues(), // TODO + "PYTHONNOUSERSITE": carapace.ActionValues("1"), + "PYTHONUNBUFFERED": carapace.ActionValues("1"), + "PYTHONVERBOSE": carapace.ActionValues("1", "2"), + "PYTHONWARNINGS": python.ActionWarningControls().List(","), + "PYTHONHASHSEED": carapace.ActionValues(), + "PYTHONINTMAXSTRDIGITS": carapace.ActionValues(), + "PYTHONMALLOC": carapace.ActionValues("malloc", "pymalloc", "debug", "malloc_debug", "pymalloc_debug"), // TODO verify + "PYTHONMALLOCSTATS": carapace.ActionValues("1"), + "PYTHONASYNCIODEBUG": carapace.ActionValues("1"), + "PYTHONTRACEMALLOC": carapace.ActionValues("1", "5", "10", "25", "50", "100"), + "PYTHONFAULTHANDLER": carapace.ActionValues("1"), + "PYTHONEXECUTABLE": carapace.ActionValues(), + "PYTHONUSERBASE": carapace.ActionDirectories(), + "PYTHONPROFILEIMPORTTIME": carapace.ActionValues("1"), + "PYTHONBREAKPOINT": carapace.ActionValuesDescribed("0", "disable"), // TODO debuggers + "PYTHONTHREADDEBUG": carapace.ActionValues("1"), + "PYTHONDUMPREFS": carapace.ActionValues("1"), + }, + } } } diff --git a/pkg/actions/env/rust.go b/pkg/actions/env/rust.go index 478b40f750..bbc621096d 100644 --- a/pkg/actions/env/rust.go +++ b/pkg/actions/env/rust.go @@ -7,21 +7,22 @@ import ( ) func init() { - _bool := carapace.ActionValuesDescribed("0", "disabled", "1", "enabled").StyleF(style.ForKeyword) - knownVariables["rust"] = variables{ - Condition: conditions.ConditionPath("rustc"), - Variables: map[string]string{ - "RUST_TEST_THREADS": "The test framework Rust provides executes tests in parallel", - "RUST_TEST_NOCAPTURE": "Synonym for the --nocapture flag", - "RUST_MIN_STACK": "Sets the minimum stack size for new threads", - "RUST_BACKTRACE": "Produces a backtrace in the output of a program which panics", - }, - VariableCompletion: map[string]carapace.Action{ - "RUST_TEST_THREADS": carapace.ActionValues(), - "RUST_TEST_NOCAPTURE": _bool, - "RUST_MIN_STACK": carapace.ActionValues(), - "RUST_BACKTRACE": _bool, - }, + knownVariables["rust"] = func() variables { + _bool := carapace.ActionValuesDescribed("0", "disabled", "1", "enabled").StyleF(style.ForKeyword) + return variables{ + Condition: conditions.ConditionPath("rustc"), + Variables: map[string]string{ + "RUST_TEST_THREADS": "The test framework Rust provides executes tests in parallel", + "RUST_TEST_NOCAPTURE": "Synonym for the --nocapture flag", + "RUST_MIN_STACK": "Sets the minimum stack size for new threads", + "RUST_BACKTRACE": "Produces a backtrace in the output of a program which panics", + }, + VariableCompletion: map[string]carapace.Action{ + "RUST_TEST_THREADS": carapace.ActionValues(), + "RUST_TEST_NOCAPTURE": _bool, + "RUST_MIN_STACK": carapace.ActionValues(), + "RUST_BACKTRACE": _bool, + }, + } } - } diff --git a/pkg/actions/env/starship.go b/pkg/actions/env/starship.go index c7ab4335f9..56db5aa4f2 100644 --- a/pkg/actions/env/starship.go +++ b/pkg/actions/env/starship.go @@ -7,34 +7,35 @@ import ( ) func init() { - knownVariables["starship"] = variables{ - Condition: conditions.ConditionPath("starship"), - Variables: map[string]string{ - "STARSHIP_CACHE": "cache location", - "STARSHIP_CONFIG": "config location", - "STARSHIP_LOG": "log level", - "STARSHIP_NUM_THREADS": "number of threads", - "STARSHIP_SESSION_KEY": "session key", - "STARSHIP_SHELL": "shell", - }, - VariableCompletion: map[string]carapace.Action{ - "STARSHIP_CACHE": carapace.ActionDirectories(), - "STARSHIP_CONFIG": carapace.ActionFiles(), - "STARSHIP_LOG": carapace.ActionValues("debug", "error", "info", "trace", "warn").StyleF(style.ForLogLevel), - "STARSHIP_SHELL": carapace.ActionValues( - "bash", - "cmd", - "elvish", - "fish", - "ion", - "nu", - "powershell", - "pwsh", - "tcsh", - "xonsh", - "zsh", - ), - }, + knownVariables["starship"] = func() variables { + return variables{ + Condition: conditions.ConditionPath("starship"), + Variables: map[string]string{ + "STARSHIP_CACHE": "cache location", + "STARSHIP_CONFIG": "config location", + "STARSHIP_LOG": "log level", + "STARSHIP_NUM_THREADS": "number of threads", + "STARSHIP_SESSION_KEY": "session key", + "STARSHIP_SHELL": "shell", + }, + VariableCompletion: map[string]carapace.Action{ + "STARSHIP_CACHE": carapace.ActionDirectories(), + "STARSHIP_CONFIG": carapace.ActionFiles(), + "STARSHIP_LOG": carapace.ActionValues("debug", "error", "info", "trace", "warn").StyleF(style.ForLogLevel), + "STARSHIP_SHELL": carapace.ActionValues( + "bash", + "cmd", + "elvish", + "fish", + "ion", + "nu", + "powershell", + "pwsh", + "tcsh", + "xonsh", + "zsh", + ), + }, + } } - } diff --git a/pkg/actions/env/terraform.go b/pkg/actions/env/terraform.go index 3bfd249dde..7447ef6d95 100644 --- a/pkg/actions/env/terraform.go +++ b/pkg/actions/env/terraform.go @@ -9,82 +9,84 @@ import ( ) func init() { - _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) - knownVariables["terraform"] = variables{ - Condition: conditions.ConditionPath("terraform"), - Variables: map[string]string{ - "TF_LOG": "Enables detailed logs to appear on stderr which is useful for debugging", - "TF_LOG_PATH": "This specifies where the log should persist its output to", - "TF_INPUT": "If set to \"false\" or \"0\", causes terraform commands to behave as if the -input=false flag was specified", - "TF_CLI_ARGS": "Additional cli arguments", - "TF_CLI_ARGS_init": "Additional cli arguments to init", - "TF_CLI_ARGS_validate": "Additional cli arguments to validate", - "TF_CLI_ARGS_plan": "Additional cli arguments to plan", - "TF_CLI_ARGS_apply": "Additional cli arguments to apply", - "TF_CLI_ARGS_destroy": "Additional cli arguments to destroy", - "TF_CLI_ARGS_console": "Additional cli arguments to console", - "TF_CLI_ARGS_fmt": "Additional cli arguments to fmt", - "TF_CLI_ARGS_force-unlock": "Additional cli arguments to force-unlock", - "TF_CLI_ARGS_get": "Additional cli arguments to get", - "TF_CLI_ARGS_graph": "Additional cli arguments to graph", - "TF_CLI_ARGS_import": "Additional cli arguments to import", - "TF_CLI_ARGS_login": "Additional cli arguments to login", - "TF_CLI_ARGS_logout": "Additional cli arguments to logout", - "TF_CLI_ARGS_metadata": "Additional cli arguments to metadata", - "TF_CLI_ARGS_output": "Additional cli arguments to output", - "TF_CLI_ARGS_providers": "Additional cli arguments to providers", - "TF_CLI_ARGS_refresh": "Additional cli arguments to refresh", - "TF_CLI_ARGS_show": "Additional cli arguments to show", - "TF_CLI_ARGS_state": "Additional cli arguments to state", - "TF_CLI_ARGS_taint": "Additional cli arguments to taint", - "TF_CLI_ARGS_test": "Additional cli arguments to test", - "TF_CLI_ARGS_untaint": "Additional cli arguments to untaint", - "TF_CLI_ARGS_version": "Additional cli arguments to version", - "TF_CLI_ARGS_workspace": "Additional cli arguments to workspace", - "TF_DATA_DIR": "Changes the location where Terraform keeps its per-working-directory data", - "TF_WORKSPACE": "Selects the workspace", - "TF_IN_AUTOMATION": "Adjusts its output to avoid suggesting specific commands to run next", - "TF_REGISTRY_DISCOVERY_RETRY": "Max number of request retries the remote registry client will attempt", - "TF_REGISTRY_CLIENT_TIMEOUT": "Client timeout for requests ", - "TF_CLI_CONFIG_FILE": "Location of the Terraform CLI configuration file", - "TF_PLUGIN_CACHE_DIR": "Plugin cache directory", - "TF_IGNORE": "When set to \"trace\", Terraform will output debug messages to display ignored files and folder", - }, - VariableCompletion: map[string]carapace.Action{ - "TF_LOG": _bool, - "TF_LOG_PATH": carapace.ActionValues(), - "TF_INPUT": carapace.ActionFiles(), - "TF_CLI_ARGS": bridge.ActionCarapaceBin("terraform").Split(), - "TF_CLI_ARGS_init": bridge.ActionCarapaceBin("terraform", "init").Split(), - "TF_CLI_ARGS_validate": bridge.ActionCarapaceBin("terraform", "validate").Split(), - "TF_CLI_ARGS_plan": bridge.ActionCarapaceBin("terraform", "plan").Split(), - "TF_CLI_ARGS_apply": bridge.ActionCarapaceBin("terraform", "apply").Split(), - "TF_CLI_ARGS_destroy": bridge.ActionCarapaceBin("terraform", "destroy").Split(), - "TF_CLI_ARGS_console": bridge.ActionCarapaceBin("terraform", "console").Split(), - "TF_CLI_ARGS_fmt": bridge.ActionCarapaceBin("terraform", "fmt").Split(), - "TF_CLI_ARGS_force-unlock": bridge.ActionCarapaceBin("terraform", "force-unlock").Split(), - "TF_CLI_ARGS_get": bridge.ActionCarapaceBin("terraform", "get").Split(), - "TF_CLI_ARGS_graph": bridge.ActionCarapaceBin("terraform", "graph").Split(), - "TF_CLI_ARGS_import": bridge.ActionCarapaceBin("terraform", "import").Split(), - "TF_CLI_ARGS_login": bridge.ActionCarapaceBin("terraform", "login").Split(), - "TF_CLI_ARGS_logout": bridge.ActionCarapaceBin("terraform", "logout").Split(), - "TF_CLI_ARGS_metadata": bridge.ActionCarapaceBin("terraform", "metadata").Split(), - "TF_CLI_ARGS_output": bridge.ActionCarapaceBin("terraform", "output").Split(), - "TF_CLI_ARGS_providers": bridge.ActionCarapaceBin("terraform", "providers").Split(), - "TF_CLI_ARGS_refresh": bridge.ActionCarapaceBin("terraform", "refresh").Split(), - "TF_CLI_ARGS_show": bridge.ActionCarapaceBin("terraform", "show").Split(), - "TF_CLI_ARGS_state": bridge.ActionCarapaceBin("terraform", "state").Split(), - "TF_CLI_ARGS_taint": bridge.ActionCarapaceBin("terraform", "taint").Split(), - "TF_CLI_ARGS_test": bridge.ActionCarapaceBin("terraform", "test").Split(), - "TF_CLI_ARGS_untaint": bridge.ActionCarapaceBin("terraform", "untaint").Split(), - "TF_CLI_ARGS_version": bridge.ActionCarapaceBin("terraform", "version").Split(), - "TF_CLI_ARGS_workspace": bridge.ActionCarapaceBin("terraform", "workspace").Split(), - "TF_DATA_DIR": carapace.ActionDirectories(), - "TF_WORKSPACE": terraform.ActionWorkspaces(), - "TF_IN_AUTOMATION": _bool, - "TF_CLI_CONFIG_FILE": carapace.ActionFiles(), - "TF_PLUGIN_CACHE_DIR": carapace.ActionDirectories(), - "TF_IGNORE": carapace.ActionValues("trace").StyleF(style.ForLogLevel), - }, + knownVariables["terraform"] = func() variables { + _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) + return variables{ + Condition: conditions.ConditionPath("terraform"), + Variables: map[string]string{ + "TF_LOG": "Enables detailed logs to appear on stderr which is useful for debugging", + "TF_LOG_PATH": "This specifies where the log should persist its output to", + "TF_INPUT": "If set to \"false\" or \"0\", causes terraform commands to behave as if the -input=false flag was specified", + "TF_CLI_ARGS": "Additional cli arguments", + "TF_CLI_ARGS_init": "Additional cli arguments to init", + "TF_CLI_ARGS_validate": "Additional cli arguments to validate", + "TF_CLI_ARGS_plan": "Additional cli arguments to plan", + "TF_CLI_ARGS_apply": "Additional cli arguments to apply", + "TF_CLI_ARGS_destroy": "Additional cli arguments to destroy", + "TF_CLI_ARGS_console": "Additional cli arguments to console", + "TF_CLI_ARGS_fmt": "Additional cli arguments to fmt", + "TF_CLI_ARGS_force-unlock": "Additional cli arguments to force-unlock", + "TF_CLI_ARGS_get": "Additional cli arguments to get", + "TF_CLI_ARGS_graph": "Additional cli arguments to graph", + "TF_CLI_ARGS_import": "Additional cli arguments to import", + "TF_CLI_ARGS_login": "Additional cli arguments to login", + "TF_CLI_ARGS_logout": "Additional cli arguments to logout", + "TF_CLI_ARGS_metadata": "Additional cli arguments to metadata", + "TF_CLI_ARGS_output": "Additional cli arguments to output", + "TF_CLI_ARGS_providers": "Additional cli arguments to providers", + "TF_CLI_ARGS_refresh": "Additional cli arguments to refresh", + "TF_CLI_ARGS_show": "Additional cli arguments to show", + "TF_CLI_ARGS_state": "Additional cli arguments to state", + "TF_CLI_ARGS_taint": "Additional cli arguments to taint", + "TF_CLI_ARGS_test": "Additional cli arguments to test", + "TF_CLI_ARGS_untaint": "Additional cli arguments to untaint", + "TF_CLI_ARGS_version": "Additional cli arguments to version", + "TF_CLI_ARGS_workspace": "Additional cli arguments to workspace", + "TF_DATA_DIR": "Changes the location where Terraform keeps its per-working-directory data", + "TF_WORKSPACE": "Selects the workspace", + "TF_IN_AUTOMATION": "Adjusts its output to avoid suggesting specific commands to run next", + "TF_REGISTRY_DISCOVERY_RETRY": "Max number of request retries the remote registry client will attempt", + "TF_REGISTRY_CLIENT_TIMEOUT": "Client timeout for requests ", + "TF_CLI_CONFIG_FILE": "Location of the Terraform CLI configuration file", + "TF_PLUGIN_CACHE_DIR": "Plugin cache directory", + "TF_IGNORE": "When set to \"trace\", Terraform will output debug messages to display ignored files and folder", + }, + VariableCompletion: map[string]carapace.Action{ + "TF_LOG": _bool, + "TF_LOG_PATH": carapace.ActionValues(), + "TF_INPUT": carapace.ActionFiles(), + "TF_CLI_ARGS": bridge.ActionCarapaceBin("terraform").Split(), + "TF_CLI_ARGS_init": bridge.ActionCarapaceBin("terraform", "init").Split(), + "TF_CLI_ARGS_validate": bridge.ActionCarapaceBin("terraform", "validate").Split(), + "TF_CLI_ARGS_plan": bridge.ActionCarapaceBin("terraform", "plan").Split(), + "TF_CLI_ARGS_apply": bridge.ActionCarapaceBin("terraform", "apply").Split(), + "TF_CLI_ARGS_destroy": bridge.ActionCarapaceBin("terraform", "destroy").Split(), + "TF_CLI_ARGS_console": bridge.ActionCarapaceBin("terraform", "console").Split(), + "TF_CLI_ARGS_fmt": bridge.ActionCarapaceBin("terraform", "fmt").Split(), + "TF_CLI_ARGS_force-unlock": bridge.ActionCarapaceBin("terraform", "force-unlock").Split(), + "TF_CLI_ARGS_get": bridge.ActionCarapaceBin("terraform", "get").Split(), + "TF_CLI_ARGS_graph": bridge.ActionCarapaceBin("terraform", "graph").Split(), + "TF_CLI_ARGS_import": bridge.ActionCarapaceBin("terraform", "import").Split(), + "TF_CLI_ARGS_login": bridge.ActionCarapaceBin("terraform", "login").Split(), + "TF_CLI_ARGS_logout": bridge.ActionCarapaceBin("terraform", "logout").Split(), + "TF_CLI_ARGS_metadata": bridge.ActionCarapaceBin("terraform", "metadata").Split(), + "TF_CLI_ARGS_output": bridge.ActionCarapaceBin("terraform", "output").Split(), + "TF_CLI_ARGS_providers": bridge.ActionCarapaceBin("terraform", "providers").Split(), + "TF_CLI_ARGS_refresh": bridge.ActionCarapaceBin("terraform", "refresh").Split(), + "TF_CLI_ARGS_show": bridge.ActionCarapaceBin("terraform", "show").Split(), + "TF_CLI_ARGS_state": bridge.ActionCarapaceBin("terraform", "state").Split(), + "TF_CLI_ARGS_taint": bridge.ActionCarapaceBin("terraform", "taint").Split(), + "TF_CLI_ARGS_test": bridge.ActionCarapaceBin("terraform", "test").Split(), + "TF_CLI_ARGS_untaint": bridge.ActionCarapaceBin("terraform", "untaint").Split(), + "TF_CLI_ARGS_version": bridge.ActionCarapaceBin("terraform", "version").Split(), + "TF_CLI_ARGS_workspace": bridge.ActionCarapaceBin("terraform", "workspace").Split(), + "TF_DATA_DIR": carapace.ActionDirectories(), + "TF_WORKSPACE": terraform.ActionWorkspaces(), + "TF_IN_AUTOMATION": _bool, + "TF_CLI_CONFIG_FILE": carapace.ActionFiles(), + "TF_PLUGIN_CACHE_DIR": carapace.ActionDirectories(), + "TF_IGNORE": carapace.ActionValues("trace").StyleF(style.ForLogLevel), + }, + } } } diff --git a/pkg/actions/env/terragrunt.go b/pkg/actions/env/terragrunt.go index 7bb927edbd..c081137eb6 100644 --- a/pkg/actions/env/terragrunt.go +++ b/pkg/actions/env/terragrunt.go @@ -7,64 +7,66 @@ import ( ) func init() { - _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) - knownVariables["terragrunt"] = variables{ - Condition: conditions.ConditionPath("terragrunt"), - Variables: map[string]string{ - "TERRAGRUNT_CONFIG": "The path to the Terragrunt config file. Default is terragrunt.hcl.", - "TERRAGRUNT_TFPATH": "Path to the Terraform binary. Default is terraform (on PATH).", - "TERRAGRUNT_NO_AUTO_INIT": "Don't automatically run 'terraform init' during other terragrunt commands. You must run 'terragrunt init' manually.", - "TERRAGRUNT_NO_AUTO_RETRY": "Don't automatically re-run command in case of transient errors.", - "TERRAGRUNT_NO_AUTO_APPROVE": "Don't automatically append `-auto-approve` to the underlying Terraform commands run with 'run-all'.", - "TERRAGRUNT_NON_INTERACTIVE": `Assume "yes" for all prompts.`, - "TERRAGRUNT_WORKING_DIR": "The path to the Terraform templates. Default is current directory.", - "TERRAGRUNT_DOWNLOAD": "The path where to download Terraform code. Default is .terragrunt-cache in the working directory.", - "TERRAGRUNT_SOURCE": "Download Terraform configurations from the specified source into a temporary folder, and run Terraform in that temporary folder.", - "TERRAGRUNT_SOURCE_UPDATE": "Delete the contents of the temporary folder to clear out any old, cached source code before downloading new source code into it.", - "TERRAGRUNT_SOURCE_MAP": "Replace any source URL (including the source URL of a config pulled in with dependency blocks) that has root source with dest.", - "TERRAGRUNT_IAM_ROLE": "Assume the specified IAM role before executing Terraform. Can also be set via the TERRAGRUNT_IAM_ROLE environment variable.", - "TERRAGRUNT_IAM_ASSUME_ROLE_DURATION": "Session duration for IAM Assume Role session. Can also be set via the TERRAGRUNT_IAM_ASSUME_ROLE_DURATION environment variable.", - "TERRAGRUNT_IAM_ASSUME_ROLE_SESSION_NAME": "Name for the IAM Assummed Role session. Can also be set via TERRAGRUNT_IAM_ASSUME_ROLE_SESSION_NAME environment variable.", - "TERRAGRUNT_INCLUDE_EXTERNAL_DEPENDENCIES": "*-all commands will include external dependencies", - "TERRAGRUNT_PARALLELISM": "*-all commands parallelism set to at most N modules", - "TERRAGRUNT_EXCLUDE_DIR": "Unix-style glob of directories to exclude when running *-all commands.", - "TERRAGRUNT_DEBUG": "Write terragrunt-debug.tfvars to working folder to help root-cause issues.", - "TERRAGRUNT_LOG_LEVEL": "Sets the logging level for Terragrunt. Supported levels: panic, fatal, error, warn, info, debug, trace.", - "TERRAGRUNT_NO_COLOR": "If specified, Terragrunt output won't contain any color.", - "TERRAGRUNT_USE_PARTIAL_PARSE_CONFIG_CACHE": "Enables caching of includes during partial parsing operations. Will also be used for the terragrunt-iam-role option if provided.", - "TERRAGRUNT_FETCH_DEPENDENCY_OUTPUT_FROM_STATE": "The option fetchs dependency output directly from the state file instead of init dependencies and running terraform on them.", - "TERRAGRUNT_INCLUDE_MODULE_PREFIX": "When this flag is set output from Terraform sub-commands is prefixed with module path.", - "TERRAGRUNT_FAIL_ON_STATE_BUCKET_CREATION": "When this flag is set Terragrunt will fail if the remote state bucket needs to be created.", - "TERRAGRUNT_DISABLE_BUCKET_UPDATE": "When this flag is set Terragrunt will not update the remote state bucket.", - "TERRAGRUNT_DISABLE_COMMAND_VALIDATION": "When this flag is set, Terragrunt will not validate the terraform command.", - }, - VariableCompletion: map[string]carapace.Action{ - "TERRAGRUNT_CONFIG": carapace.ActionFiles(), - "TERRAGRUNT_TFPATH": carapace.ActionFiles(), - "TERRAGRUNT_NO_AUTO_INIT": _bool, - "TERRAGRUNT_NO_AUTO_RETRY": _bool, - "TERRAGRUNT_NO_AUTO_APPROVE": _bool, - "TERRAGRUNT_NON_INTERACTIVE": _bool, - "TERRAGRUNT_WORKING_DIR": carapace.ActionDirectories(), - "TERRAGRUNT_DOWNLOAD": carapace.ActionDirectories(), - // "TERRAGRUNT_SOURCE": carapace.ActionValues(), // TODO - "TERRAGRUNT_SOURCE_UPDATE": _bool, - "TERRAGRUNT_SOURCE_MAP": carapace.ActionValues(), - "TERRAGRUNT_IAM_ROLE": carapace.ActionValues(), - "TERRAGRUNT_IAM_ASSUME_ROLE_DURATION": carapace.ActionValues(), - "TERRAGRUNT_IAM_ASSUME_ROLE_SESSION_NAME": carapace.ActionValues(), - "TERRAGRUNT_INCLUDE_EXTERNAL_DEPENDENCIES": _bool, - "TERRAGRUNT_PARALLELISM": carapace.ActionValues(), - "TERRAGRUNT_EXCLUDE_DIR": carapace.ActionDirectories(), - "TERRAGRUNT_DEBUG": _bool, - "TERRAGRUNT_LOG_LEVEL": carapace.ActionValues("panic", "fatal", "error", "warn", "info", "debug", "trace").StyleF(style.ForLogLevel), - "TERRAGRUNT_NO_COLOR": _bool, - "TERRAGRUNT_USE_PARTIAL_PARSE_CONFIG_CACHE": _bool, - "TERRAGRUNT_FETCH_DEPENDENCY_OUTPUT_FROM_STATE": _bool, - "TERRAGRUNT_INCLUDE_MODULE_PREFIX": _bool, - "TERRAGRUNT_FAIL_ON_STATE_BUCKET_CREATION": _bool, - "TERRAGRUNT_DISABLE_BUCKET_UPDATE": _bool, - "TERRAGRUNT_DISABLE_COMMAND_VALIDATION": _bool, - }, + knownVariables["terragrunt"] = func() variables { + _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) + return variables{ + Condition: conditions.ConditionPath("terragrunt"), + Variables: map[string]string{ + "TERRAGRUNT_CONFIG": "The path to the Terragrunt config file. Default is terragrunt.hcl.", + "TERRAGRUNT_TFPATH": "Path to the Terraform binary. Default is terraform (on PATH).", + "TERRAGRUNT_NO_AUTO_INIT": "Don't automatically run 'terraform init' during other terragrunt commands. You must run 'terragrunt init' manually.", + "TERRAGRUNT_NO_AUTO_RETRY": "Don't automatically re-run command in case of transient errors.", + "TERRAGRUNT_NO_AUTO_APPROVE": "Don't automatically append `-auto-approve` to the underlying Terraform commands run with 'run-all'.", + "TERRAGRUNT_NON_INTERACTIVE": `Assume "yes" for all prompts.`, + "TERRAGRUNT_WORKING_DIR": "The path to the Terraform templates. Default is current directory.", + "TERRAGRUNT_DOWNLOAD": "The path where to download Terraform code. Default is .terragrunt-cache in the working directory.", + "TERRAGRUNT_SOURCE": "Download Terraform configurations from the specified source into a temporary folder, and run Terraform in that temporary folder.", + "TERRAGRUNT_SOURCE_UPDATE": "Delete the contents of the temporary folder to clear out any old, cached source code before downloading new source code into it.", + "TERRAGRUNT_SOURCE_MAP": "Replace any source URL (including the source URL of a config pulled in with dependency blocks) that has root source with dest.", + "TERRAGRUNT_IAM_ROLE": "Assume the specified IAM role before executing Terraform. Can also be set via the TERRAGRUNT_IAM_ROLE environment variable.", + "TERRAGRUNT_IAM_ASSUME_ROLE_DURATION": "Session duration for IAM Assume Role session. Can also be set via the TERRAGRUNT_IAM_ASSUME_ROLE_DURATION environment variable.", + "TERRAGRUNT_IAM_ASSUME_ROLE_SESSION_NAME": "Name for the IAM Assummed Role session. Can also be set via TERRAGRUNT_IAM_ASSUME_ROLE_SESSION_NAME environment variable.", + "TERRAGRUNT_INCLUDE_EXTERNAL_DEPENDENCIES": "*-all commands will include external dependencies", + "TERRAGRUNT_PARALLELISM": "*-all commands parallelism set to at most N modules", + "TERRAGRUNT_EXCLUDE_DIR": "Unix-style glob of directories to exclude when running *-all commands.", + "TERRAGRUNT_DEBUG": "Write terragrunt-debug.tfvars to working folder to help root-cause issues.", + "TERRAGRUNT_LOG_LEVEL": "Sets the logging level for Terragrunt. Supported levels: panic, fatal, error, warn, info, debug, trace.", + "TERRAGRUNT_NO_COLOR": "If specified, Terragrunt output won't contain any color.", + "TERRAGRUNT_USE_PARTIAL_PARSE_CONFIG_CACHE": "Enables caching of includes during partial parsing operations. Will also be used for the terragrunt-iam-role option if provided.", + "TERRAGRUNT_FETCH_DEPENDENCY_OUTPUT_FROM_STATE": "The option fetchs dependency output directly from the state file instead of init dependencies and running terraform on them.", + "TERRAGRUNT_INCLUDE_MODULE_PREFIX": "When this flag is set output from Terraform sub-commands is prefixed with module path.", + "TERRAGRUNT_FAIL_ON_STATE_BUCKET_CREATION": "When this flag is set Terragrunt will fail if the remote state bucket needs to be created.", + "TERRAGRUNT_DISABLE_BUCKET_UPDATE": "When this flag is set Terragrunt will not update the remote state bucket.", + "TERRAGRUNT_DISABLE_COMMAND_VALIDATION": "When this flag is set, Terragrunt will not validate the terraform command.", + }, + VariableCompletion: map[string]carapace.Action{ + "TERRAGRUNT_CONFIG": carapace.ActionFiles(), + "TERRAGRUNT_TFPATH": carapace.ActionFiles(), + "TERRAGRUNT_NO_AUTO_INIT": _bool, + "TERRAGRUNT_NO_AUTO_RETRY": _bool, + "TERRAGRUNT_NO_AUTO_APPROVE": _bool, + "TERRAGRUNT_NON_INTERACTIVE": _bool, + "TERRAGRUNT_WORKING_DIR": carapace.ActionDirectories(), + "TERRAGRUNT_DOWNLOAD": carapace.ActionDirectories(), + // "TERRAGRUNT_SOURCE": carapace.ActionValues(), // TODO + "TERRAGRUNT_SOURCE_UPDATE": _bool, + "TERRAGRUNT_SOURCE_MAP": carapace.ActionValues(), + "TERRAGRUNT_IAM_ROLE": carapace.ActionValues(), + "TERRAGRUNT_IAM_ASSUME_ROLE_DURATION": carapace.ActionValues(), + "TERRAGRUNT_IAM_ASSUME_ROLE_SESSION_NAME": carapace.ActionValues(), + "TERRAGRUNT_INCLUDE_EXTERNAL_DEPENDENCIES": _bool, + "TERRAGRUNT_PARALLELISM": carapace.ActionValues(), + "TERRAGRUNT_EXCLUDE_DIR": carapace.ActionDirectories(), + "TERRAGRUNT_DEBUG": _bool, + "TERRAGRUNT_LOG_LEVEL": carapace.ActionValues("panic", "fatal", "error", "warn", "info", "debug", "trace").StyleF(style.ForLogLevel), + "TERRAGRUNT_NO_COLOR": _bool, + "TERRAGRUNT_USE_PARTIAL_PARSE_CONFIG_CACHE": _bool, + "TERRAGRUNT_FETCH_DEPENDENCY_OUTPUT_FROM_STATE": _bool, + "TERRAGRUNT_INCLUDE_MODULE_PREFIX": _bool, + "TERRAGRUNT_FAIL_ON_STATE_BUCKET_CREATION": _bool, + "TERRAGRUNT_DISABLE_BUCKET_UPDATE": _bool, + "TERRAGRUNT_DISABLE_COMMAND_VALIDATION": _bool, + }, + } } } diff --git a/pkg/actions/env/tofu.go b/pkg/actions/env/tofu.go index 34f8c60627..d27a4527b9 100644 --- a/pkg/actions/env/tofu.go +++ b/pkg/actions/env/tofu.go @@ -9,82 +9,84 @@ import ( ) func init() { - _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) - knownVariables["tofu"] = variables{ - Condition: conditions.ConditionPath("tofu"), - Variables: map[string]string{ - "TF_LOG": "Enables detailed logs to appear on stderr which is useful for debugging", - "TF_LOG_PATH": "This specifies where the log should persist its output to", - "TF_INPUT": "If set to \"false\" or \"0\", causes tofu commands to behave as if the -input=false flag was specified", - "TF_CLI_ARGS": "Additional cli arguments", - "TF_CLI_ARGS_init": "Additional cli arguments to init", - "TF_CLI_ARGS_validate": "Additional cli arguments to validate", - "TF_CLI_ARGS_plan": "Additional cli arguments to plan", - "TF_CLI_ARGS_apply": "Additional cli arguments to apply", - "TF_CLI_ARGS_destroy": "Additional cli arguments to destroy", - "TF_CLI_ARGS_console": "Additional cli arguments to console", - "TF_CLI_ARGS_fmt": "Additional cli arguments to fmt", - "TF_CLI_ARGS_force-unlock": "Additional cli arguments to force-unlock", - "TF_CLI_ARGS_get": "Additional cli arguments to get", - "TF_CLI_ARGS_graph": "Additional cli arguments to graph", - "TF_CLI_ARGS_import": "Additional cli arguments to import", - "TF_CLI_ARGS_login": "Additional cli arguments to login", - "TF_CLI_ARGS_logout": "Additional cli arguments to logout", - "TF_CLI_ARGS_metadata": "Additional cli arguments to metadata", - "TF_CLI_ARGS_output": "Additional cli arguments to output", - "TF_CLI_ARGS_providers": "Additional cli arguments to providers", - "TF_CLI_ARGS_refresh": "Additional cli arguments to refresh", - "TF_CLI_ARGS_show": "Additional cli arguments to show", - "TF_CLI_ARGS_state": "Additional cli arguments to state", - "TF_CLI_ARGS_taint": "Additional cli arguments to taint", - "TF_CLI_ARGS_test": "Additional cli arguments to test", - "TF_CLI_ARGS_untaint": "Additional cli arguments to untaint", - "TF_CLI_ARGS_version": "Additional cli arguments to version", - "TF_CLI_ARGS_workspace": "Additional cli arguments to workspace", - "TF_DATA_DIR": "Changes the location where tofu keeps its per-working-directory data", - "TF_WORKSPACE": "Selects the workspace", - "TF_IN_AUTOMATION": "Adjusts its output to avoid suggesting specific commands to run next", - "TF_REGISTRY_DISCOVERY_RETRY": "Max number of request retries the remote registry client will attempt", - "TF_REGISTRY_CLIENT_TIMEOUT": "Client timeout for requests ", - "TF_CLI_CONFIG_FILE": "Location of the tofu CLI configuration file", - "TF_PLUGIN_CACHE_DIR": "Plugin cache directory", - "TF_IGNORE": "When set to \"trace\", tofu will output debug messages to display ignored files and folder", - }, - VariableCompletion: map[string]carapace.Action{ - "TF_LOG": _bool, - "TF_LOG_PATH": carapace.ActionValues(), - "TF_INPUT": carapace.ActionFiles(), - "TF_CLI_ARGS": bridge.ActionCarapaceBin("tofu").Split(), - "TF_CLI_ARGS_init": bridge.ActionCarapaceBin("tofu", "init").Split(), - "TF_CLI_ARGS_validate": bridge.ActionCarapaceBin("tofu", "validate").Split(), - "TF_CLI_ARGS_plan": bridge.ActionCarapaceBin("tofu", "plan").Split(), - "TF_CLI_ARGS_apply": bridge.ActionCarapaceBin("tofu", "apply").Split(), - "TF_CLI_ARGS_destroy": bridge.ActionCarapaceBin("tofu", "destroy").Split(), - "TF_CLI_ARGS_console": bridge.ActionCarapaceBin("tofu", "console").Split(), - "TF_CLI_ARGS_fmt": bridge.ActionCarapaceBin("tofu", "fmt").Split(), - "TF_CLI_ARGS_force-unlock": bridge.ActionCarapaceBin("tofu", "force-unlock").Split(), - "TF_CLI_ARGS_get": bridge.ActionCarapaceBin("tofu", "get").Split(), - "TF_CLI_ARGS_graph": bridge.ActionCarapaceBin("tofu", "graph").Split(), - "TF_CLI_ARGS_import": bridge.ActionCarapaceBin("tofu", "import").Split(), - "TF_CLI_ARGS_login": bridge.ActionCarapaceBin("tofu", "login").Split(), - "TF_CLI_ARGS_logout": bridge.ActionCarapaceBin("tofu", "logout").Split(), - "TF_CLI_ARGS_metadata": bridge.ActionCarapaceBin("tofu", "metadata").Split(), - "TF_CLI_ARGS_output": bridge.ActionCarapaceBin("tofu", "output").Split(), - "TF_CLI_ARGS_providers": bridge.ActionCarapaceBin("tofu", "providers").Split(), - "TF_CLI_ARGS_refresh": bridge.ActionCarapaceBin("tofu", "refresh").Split(), - "TF_CLI_ARGS_show": bridge.ActionCarapaceBin("tofu", "show").Split(), - "TF_CLI_ARGS_state": bridge.ActionCarapaceBin("tofu", "state").Split(), - "TF_CLI_ARGS_taint": bridge.ActionCarapaceBin("tofu", "taint").Split(), - "TF_CLI_ARGS_test": bridge.ActionCarapaceBin("tofu", "test").Split(), - "TF_CLI_ARGS_untaint": bridge.ActionCarapaceBin("tofu", "untaint").Split(), - "TF_CLI_ARGS_version": bridge.ActionCarapaceBin("tofu", "version").Split(), - "TF_CLI_ARGS_workspace": bridge.ActionCarapaceBin("tofu", "workspace").Split(), - "TF_DATA_DIR": carapace.ActionDirectories(), - "TF_WORKSPACE": tofu.ActionWorkspaces(), - "TF_IN_AUTOMATION": _bool, - "TF_CLI_CONFIG_FILE": carapace.ActionFiles(), - "TF_PLUGIN_CACHE_DIR": carapace.ActionDirectories(), - "TF_IGNORE": carapace.ActionValues("trace").StyleF(style.ForLogLevel), - }, + knownVariables["tofu"] = func() variables { + _bool := carapace.ActionValues("true", "false").StyleF(style.ForKeyword) + return variables{ + Condition: conditions.ConditionPath("tofu"), + Variables: map[string]string{ + "TF_LOG": "Enables detailed logs to appear on stderr which is useful for debugging", + "TF_LOG_PATH": "This specifies where the log should persist its output to", + "TF_INPUT": "If set to \"false\" or \"0\", causes tofu commands to behave as if the -input=false flag was specified", + "TF_CLI_ARGS": "Additional cli arguments", + "TF_CLI_ARGS_init": "Additional cli arguments to init", + "TF_CLI_ARGS_validate": "Additional cli arguments to validate", + "TF_CLI_ARGS_plan": "Additional cli arguments to plan", + "TF_CLI_ARGS_apply": "Additional cli arguments to apply", + "TF_CLI_ARGS_destroy": "Additional cli arguments to destroy", + "TF_CLI_ARGS_console": "Additional cli arguments to console", + "TF_CLI_ARGS_fmt": "Additional cli arguments to fmt", + "TF_CLI_ARGS_force-unlock": "Additional cli arguments to force-unlock", + "TF_CLI_ARGS_get": "Additional cli arguments to get", + "TF_CLI_ARGS_graph": "Additional cli arguments to graph", + "TF_CLI_ARGS_import": "Additional cli arguments to import", + "TF_CLI_ARGS_login": "Additional cli arguments to login", + "TF_CLI_ARGS_logout": "Additional cli arguments to logout", + "TF_CLI_ARGS_metadata": "Additional cli arguments to metadata", + "TF_CLI_ARGS_output": "Additional cli arguments to output", + "TF_CLI_ARGS_providers": "Additional cli arguments to providers", + "TF_CLI_ARGS_refresh": "Additional cli arguments to refresh", + "TF_CLI_ARGS_show": "Additional cli arguments to show", + "TF_CLI_ARGS_state": "Additional cli arguments to state", + "TF_CLI_ARGS_taint": "Additional cli arguments to taint", + "TF_CLI_ARGS_test": "Additional cli arguments to test", + "TF_CLI_ARGS_untaint": "Additional cli arguments to untaint", + "TF_CLI_ARGS_version": "Additional cli arguments to version", + "TF_CLI_ARGS_workspace": "Additional cli arguments to workspace", + "TF_DATA_DIR": "Changes the location where tofu keeps its per-working-directory data", + "TF_WORKSPACE": "Selects the workspace", + "TF_IN_AUTOMATION": "Adjusts its output to avoid suggesting specific commands to run next", + "TF_REGISTRY_DISCOVERY_RETRY": "Max number of request retries the remote registry client will attempt", + "TF_REGISTRY_CLIENT_TIMEOUT": "Client timeout for requests ", + "TF_CLI_CONFIG_FILE": "Location of the tofu CLI configuration file", + "TF_PLUGIN_CACHE_DIR": "Plugin cache directory", + "TF_IGNORE": "When set to \"trace\", tofu will output debug messages to display ignored files and folder", + }, + VariableCompletion: map[string]carapace.Action{ + "TF_LOG": _bool, + "TF_LOG_PATH": carapace.ActionValues(), + "TF_INPUT": carapace.ActionFiles(), + "TF_CLI_ARGS": bridge.ActionCarapaceBin("tofu").Split(), + "TF_CLI_ARGS_init": bridge.ActionCarapaceBin("tofu", "init").Split(), + "TF_CLI_ARGS_validate": bridge.ActionCarapaceBin("tofu", "validate").Split(), + "TF_CLI_ARGS_plan": bridge.ActionCarapaceBin("tofu", "plan").Split(), + "TF_CLI_ARGS_apply": bridge.ActionCarapaceBin("tofu", "apply").Split(), + "TF_CLI_ARGS_destroy": bridge.ActionCarapaceBin("tofu", "destroy").Split(), + "TF_CLI_ARGS_console": bridge.ActionCarapaceBin("tofu", "console").Split(), + "TF_CLI_ARGS_fmt": bridge.ActionCarapaceBin("tofu", "fmt").Split(), + "TF_CLI_ARGS_force-unlock": bridge.ActionCarapaceBin("tofu", "force-unlock").Split(), + "TF_CLI_ARGS_get": bridge.ActionCarapaceBin("tofu", "get").Split(), + "TF_CLI_ARGS_graph": bridge.ActionCarapaceBin("tofu", "graph").Split(), + "TF_CLI_ARGS_import": bridge.ActionCarapaceBin("tofu", "import").Split(), + "TF_CLI_ARGS_login": bridge.ActionCarapaceBin("tofu", "login").Split(), + "TF_CLI_ARGS_logout": bridge.ActionCarapaceBin("tofu", "logout").Split(), + "TF_CLI_ARGS_metadata": bridge.ActionCarapaceBin("tofu", "metadata").Split(), + "TF_CLI_ARGS_output": bridge.ActionCarapaceBin("tofu", "output").Split(), + "TF_CLI_ARGS_providers": bridge.ActionCarapaceBin("tofu", "providers").Split(), + "TF_CLI_ARGS_refresh": bridge.ActionCarapaceBin("tofu", "refresh").Split(), + "TF_CLI_ARGS_show": bridge.ActionCarapaceBin("tofu", "show").Split(), + "TF_CLI_ARGS_state": bridge.ActionCarapaceBin("tofu", "state").Split(), + "TF_CLI_ARGS_taint": bridge.ActionCarapaceBin("tofu", "taint").Split(), + "TF_CLI_ARGS_test": bridge.ActionCarapaceBin("tofu", "test").Split(), + "TF_CLI_ARGS_untaint": bridge.ActionCarapaceBin("tofu", "untaint").Split(), + "TF_CLI_ARGS_version": bridge.ActionCarapaceBin("tofu", "version").Split(), + "TF_CLI_ARGS_workspace": bridge.ActionCarapaceBin("tofu", "workspace").Split(), + "TF_DATA_DIR": carapace.ActionDirectories(), + "TF_WORKSPACE": tofu.ActionWorkspaces(), + "TF_IN_AUTOMATION": _bool, + "TF_CLI_CONFIG_FILE": carapace.ActionFiles(), + "TF_PLUGIN_CACHE_DIR": carapace.ActionDirectories(), + "TF_IGNORE": carapace.ActionValues("trace").StyleF(style.ForLogLevel), + }, + } } } diff --git a/pkg/actions/env/xdg.go b/pkg/actions/env/xdg.go index 880843cfbb..ab71c97e1b 100644 --- a/pkg/actions/env/xdg.go +++ b/pkg/actions/env/xdg.go @@ -5,25 +5,26 @@ import ( ) func init() { - knownVariables["xdg"] = variables{ - Variables: map[string]string{ - "XDG_DATA_HOME": "base directory relative to which user-specific data files should be stored", - "XDG_CONFIG_HOME": "base directory relative to which user-specific configuration files should be stored", - "XDG_STATE_HOME": "base directory relative to which user-specific state files should be stored", - "XDG_DATA_DIRS": "base directories to search for data files", - "XDG_CONFIG_DIRS": "base directories to search for configuration files", - "XDG_CACHE_HOME": "base directory relative to which user-specific non-essential data files should be stored", - "XDG_RUNTIME_DIR": "base directory relative to which user-specific non-essential runtime files should be stored", - }, - VariableCompletion: map[string]carapace.Action{ - "XDG_DATA_HOME": carapace.ActionDirectories(), - "XDG_CONFIG_HOME": carapace.ActionDirectories(), - "XDG_STATE_HOME": carapace.ActionDirectories(), - "XDG_DATA_DIRS": carapace.ActionDirectories().List(":"), - "XDG_CONFIG_DIRS": carapace.ActionDirectories().List(":"), - "XDG_CACHE_HOME": carapace.ActionDirectories(), - "XDG_RUNTIME_DIR": carapace.ActionDirectories(), - }, + knownVariables["xdg"] = func() variables { + return variables{ + Variables: map[string]string{ + "XDG_DATA_HOME": "base directory relative to which user-specific data files should be stored", + "XDG_CONFIG_HOME": "base directory relative to which user-specific configuration files should be stored", + "XDG_STATE_HOME": "base directory relative to which user-specific state files should be stored", + "XDG_DATA_DIRS": "base directories to search for data files", + "XDG_CONFIG_DIRS": "base directories to search for configuration files", + "XDG_CACHE_HOME": "base directory relative to which user-specific non-essential data files should be stored", + "XDG_RUNTIME_DIR": "base directory relative to which user-specific non-essential runtime files should be stored", + }, + VariableCompletion: map[string]carapace.Action{ + "XDG_DATA_HOME": carapace.ActionDirectories(), + "XDG_CONFIG_HOME": carapace.ActionDirectories(), + "XDG_STATE_HOME": carapace.ActionDirectories(), + "XDG_DATA_DIRS": carapace.ActionDirectories().List(":"), + "XDG_CONFIG_DIRS": carapace.ActionDirectories().List(":"), + "XDG_CACHE_HOME": carapace.ActionDirectories(), + "XDG_RUNTIME_DIR": carapace.ActionDirectories(), + }, + } } - }