From 71162825dd611699cdb62f0974518c6fca2b10b6 Mon Sep 17 00:00:00 2001 From: yinchuandong Date: Thu, 3 Mar 2022 23:31:38 +1100 Subject: [PATCH 1/8] feat(minikube): add minikube dashboard --- src/minikube.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/minikube.ts b/src/minikube.ts index f2d715e10e9b..4e025a1289a2 100644 --- a/src/minikube.ts +++ b/src/minikube.ts @@ -435,6 +435,22 @@ const completionSpec: Fig.Spec = { }, ], }, + { + name: "dashboard", + description: + "Access the Kubernetes dashboard running within the minikube cluster", + options: [ + { + name: "--port", + description: + "Exposed port of the proxyfied dashboard. Set to 0 to pick a random port", + }, + { + name: "--url", + description: "Display dashboard URL instead of opening a browse", + }, + ], + }, { name: "status", description: "Gets the status of a local Kubernetes cluster", From d9e1b984acdc17bb344951cda1e73cb0b8b0b50e Mon Sep 17 00:00:00 2001 From: yinchuandong Date: Fri, 4 Mar 2022 09:57:46 +1100 Subject: [PATCH 2/8] feat(terragrunt): add terragrunt spec --- src/terragrunt.ts | 364 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 364 insertions(+) create mode 100644 src/terragrunt.ts diff --git a/src/terragrunt.ts b/src/terragrunt.ts new file mode 100644 index 000000000000..7383850f2a4b --- /dev/null +++ b/src/terragrunt.ts @@ -0,0 +1,364 @@ +const generalSubCommandOptions: Fig.Option[] = [ + { + name: "-lock", + insertValue: "-lock=", + description: + "Lock the state file when locking is supported. Defaults to true", + args: { + name: "true or false", + suggestions: ["true", "false"], + }, + }, + { + name: "-force", + insertValue: "-force=", + description: + "Delete the workspace even if its state is not empty. Defaults to false", + args: { + name: "true or false", + suggestions: ["true", "false"], + }, + }, + { + name: "-lock-timeout", + insertValue: "-lock-timeout=", + description: "Duration to retry a state lock. Default 0s", + args: { + name: "seconds", + }, + }, + { + name: "-input", + insertValue: "-input=", + description: "Ask for input for variables if not directly set", + args: { + name: "true or false", + suggestions: ["true", "false"], + }, + }, + { + name: "-no-color", + description: "Disables output with coloring", + }, +]; + +const globalOptions: Fig.Option[] = [ + { + name: "-help", + description: + "Show this help output, or the help for a specified subcommand", + }, + { + name: "-chdir", + description: + "Switch to a different working directory before executing the given subcommand", + insertValue: "-chdir=", + args: { + template: "filepaths", + }, + }, + { + name: "-version", + description: "Show the current terragrunt version", + }, + { + name: "--terragrunt-config", + description: + "Path to the Terragrunt config file. Default is terragrunt.hcl", + }, + { + name: "--terragrunt-tfpath", + description: "Path to the Terraform binary. Default is terraform (on PATH)", + }, + { + name: "--terragrunt-no-auto-init", + description: + "Don't automatically run 'terraform init' during other terragrunt commands. You must run 'terragrunt init' manually", + }, + { + name: "--terragrunt-non-interactive", + description: "Assume 'yes' for all prompts", + }, + { + name: "--terragrunt-working-dir", + description: + "The path to the Terraform templates. Default is current directory", + }, + { + name: "--terragrunt-download-dir", + description: + "The path where to download Terraform code. Default is .terragrunt-cache in the working directory", + }, + { + name: "--terragrunt-source", + description: + "Download Terraform configurations from the specified source into a temporary folder, and run Terraform in that temporary folder", + }, + { + name: "--terragrunt-source-update", + description: + "Delete the contents of the temporary folder to clear out any old, cached source code before downloading new source code into it", + }, + { + name: "--terragrunt-iam-role", + description: + "Assume the specified IAM role before executing Terraform. Can also be set via the TERRAGRUNT_IAM_ROLE environment variable", + }, + { + name: "--terragrunt-ignore-dependency-errors", + description: + "*-all commands continue processing components even if a dependency fails", + }, + { + name: "--terragrunt-ignore-dependency-order", + description: "*-all commands will be run disregarding the dependencie", + }, + { + name: "--terragrunt-ignore-external-dependencies", + description: + "*-all commands will not attempt to include external dependencies", + }, + { + name: "--terragrunt-include-external-dependencies", + description: "*-all commands will include external dependencies", + }, + { + name: "--terragrunt-parallelism ", + description: "*-all commands parallelism set to at most N module", + }, + { + name: "--terragrunt-exclude-dir", + description: + "Unix-style glob of directories to exclude when running *-all commands", + }, + { + name: "--terragrunt-include-dir", + description: + "Unix-style glob of directories to include when running *-all command", + }, + { + name: "--terragrunt-check", + description: "Enable check mode in the hclfmt command", + }, + { + name: "--terragrunt-hclfmt-file", + description: + "The path to a single terragrunt.hcl file that the hclfmt command should run on", + }, + { + name: "--terragrunt-override-attr", + description: + "A key=value attribute to override in a provider block as part of the aws-provider-patch command. May be specified multiple times", + }, + { + name: "--terragrunt-debug", + description: + "Write terragrunt-debug.tfvars to working folder to help root-cause issues", + }, + { + name: "--terragrunt-log-level", + description: + "Sets the logging level for Terragrunt. Supported levels: panic, fatal, error, warn (default), info, debug, trace", + }, +]; + +const mainCommands: Fig.Subcommand[] = [ + { + name: "init", + description: "Prepare your working directory for other commands", + options: [ + { + name: "-upgrade", + description: + "Opt to upgrade modules and plugins as part of their respective installation steps", + }, + ...generalSubCommandOptions, + ...globalOptions, + ], + }, + { + name: "validate", + description: "Check whether the configuration is valid", + options: [...globalOptions], + }, + { + name: "plan", + description: "Show changes required by the current configuration", + options: [ + { + name: "-compact-warnings", + description: + "If terragrunt produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages", + }, + { + name: "-destroy", + description: + "If set, generates a plan to destroy all the known resources", + }, + { + name: "-detailed-exitcode", + description: "Return a detailed exit code when the command exits", + }, + { + name: "-out", + insertValue: "-out=", + description: "The path to save the generated execution plan", + }, + { + name: "-parallelism", + description: + "Limit the number of concurrent operation as terragrunt walks the graph. Defaults to 10", + args: { + name: "number", + }, + }, + { + name: "-refresh", + insertValue: "-refresh=", + description: "Update the state prior to checking for differences", + args: { + name: "true or false", + suggestions: ["true", "false"], + }, + }, + { + name: "-state", + insertValue: "-state=", + description: + "Path to the state file. Defaults to 'terragrunt.tfstate'. Ignored when remote state is used", + args: { + template: "filepaths", + }, + }, + { + name: "-target", + displayName: "-target=resource", + description: + "A Resource Address to target. This flag can be used multiple times", + isRepeatable: true, + }, + { + name: "-var", + insertValue: "-var {cursor}", + description: + "Set a variable in the terragrunt configuration. This flag can be set multiple times", + isRepeatable: true, + args: { + name: "foo=bar", + }, + }, + + { + name: "-var-file", + insertValue: "-var-file=", + description: + "Set variables in the terragrunt configuration from a variable file", + args: { + template: "filepaths", + }, + }, + ...generalSubCommandOptions, + ...globalOptions, + ], + }, + { + name: "apply", + description: "Create or update infrastructure", + options: [...globalOptions], + }, + { + name: "destroy", + description: "Destroy previously-created infrastructure", + options: [...globalOptions], + }, + { + name: "run-all", + description: + "Run a terraform command against a 'stack' by running the specified command in each subfolder. E.g., to run 'terragrunt apply' in each subfolder, use 'terragrunt run-all apply", + subcommands: [ + { + name: "plan", + description: + "Display the plans of a ‘stack’ by running ‘terragrunt plan’ in each subfolder", + options: [...globalOptions], + }, + { + name: "apply", + description: + "Apply a ‘stack’ by running ‘terragrunt apply’ in each subfolder", + options: [...globalOptions], + }, + { + name: "output", + description: + "Display the outputs of a ‘stack’ by running ‘terragrunt output’ in each subfolder", + options: [...globalOptions], + }, + { + name: "destroy", + description: + "Destroy a ‘stack’ by running ‘terragrunt destroy’ in each subfolder", + options: [...globalOptions], + }, + { + name: "validate", + description: + "Validate a ‘stack’ by running ‘terragrunt destroy’ in each subfolder", + options: [...globalOptions], + }, + ], + options: [...globalOptions], + }, +]; + +const otherCommands: Fig.Subcommand[] = [ + { + name: "terragrunt-info", + description: + "Emits limited terragrunt state on stdout in a JSON format and exits", + }, + { + name: "graph-dependencies", + description: + "Prints the terragrunt dependency graph, in DOT format, to stdout", + }, + { + name: "hclfmt", + description: + "Recursively find hcl files and rewrite them into a canonical format", + }, + { + name: "validate-inputs", + description: + "Emits information about the input variables that are configured with the given terragrunt configuration", + options: [ + { + name: "--terragrunt-strict-validate", + description: "Enable strict mode", + }, + ], + }, + { + name: "render-json", + description: "Render out the final interpreted terragrunt.hcl file", + options: [ + { + name: "--terragrunt-json-out", + description: + "Configure where terragrunt renders out the json representation", + }, + ], + }, +]; + +const completionSpec: Fig.Spec = { + name: "terragrunt", + description: "Terragrunt CLI", + options: globalOptions, + parserDirectives: { + flagsArePosixNoncompliant: true, + }, + subcommands: [...mainCommands, ...otherCommands], +}; + +export default completionSpec; From 8c936f4a26aee80591e538f1145e09bb7cfa9c98 Mon Sep 17 00:00:00 2001 From: yinchuandong Date: Fri, 4 Mar 2022 12:38:18 +1100 Subject: [PATCH 3/8] feat(tgenv): add tgenv specs --- src/tgenv.ts | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/tgenv.ts diff --git a/src/tgenv.ts b/src/tgenv.ts new file mode 100644 index 000000000000..d785b61ebc85 --- /dev/null +++ b/src/tgenv.ts @@ -0,0 +1,73 @@ +const generators: Record = { + installedVersions: { + script: "tgenv list", + postProcess: function (out) { + return out.split("\n").map((tfversion) => { + return { name: tfversion, description: "Version" }; + }); + }, + }, + allVersions: { + script: "tgenv list-remote", + postProcess: function (out) { + return out.split("\n").map(function (line) { + return { name: line, type: "option" }; + }); + }, + }, +}; + +const completionSpec: Fig.Spec = { + name: "tgenv", + description: "Terragrunt version manager", + subcommands: [ + { + name: "install", + description: "Install a specific version of Terragrunt", + args: { + name: "version", + description: "Possible Terragrunt Version", + suggestions: ["latest", "min-required"], + generators: generators.allVersions, + }, + }, + { + name: "use", + description: "Switch to a version to use", + args: { + name: "version", + description: "Installed Terragrunt Version", + generators: generators.installedVersions, + }, + }, + { + name: "uninstall", + description: "Uninstall a specific version of Terragrunt", + args: { + name: "version", + description: "Installed Terragrunt Version", + generators: generators.installedVersions, + }, + }, + { + name: "list", + description: "List all installed versions", + }, + { + name: "list-remote", + description: "List all installable versions", + }, + ], + options: [ + { + name: ["-v", "--version"], + description: "View your current tgenv version", + }, + { + name: "--help", + description: "View commands", + }, + ], +}; + +export default completionSpec; From 1016fe21ae31e0db4f754d4ab54a7d9ebcefe1b0 Mon Sep 17 00:00:00 2001 From: yinchuandong Date: Tue, 15 Mar 2022 21:48:50 +1100 Subject: [PATCH 4/8] fix(tgenv): add trim in generators --- src/tgenv.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/tgenv.ts b/src/tgenv.ts index d785b61ebc85..361b8a9d9b19 100644 --- a/src/tgenv.ts +++ b/src/tgenv.ts @@ -2,17 +2,23 @@ const generators: Record = { installedVersions: { script: "tgenv list", postProcess: function (out) { - return out.split("\n").map((tfversion) => { - return { name: tfversion, description: "Version" }; - }); + return out + .trim() + .split("\n") + .map((tfversion) => { + return { name: tfversion, description: "Version" }; + }); }, }, allVersions: { script: "tgenv list-remote", postProcess: function (out) { - return out.split("\n").map(function (line) { - return { name: line, type: "option" }; - }); + return out + .trim() + .split("\n") + .map(function (line) { + return { name: line, type: "option" }; + }); }, }, }; From 7dab86d532ba3898173a0bc9f6dbf67e710598d5 Mon Sep 17 00:00:00 2001 From: yinchuandong Date: Tue, 15 Mar 2022 21:49:10 +1100 Subject: [PATCH 5/8] fix(minikube): add args name for dashboard --- src/minikube.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/minikube.ts b/src/minikube.ts index 4e025a1289a2..a7295d008bf1 100644 --- a/src/minikube.ts +++ b/src/minikube.ts @@ -444,6 +444,9 @@ const completionSpec: Fig.Spec = { name: "--port", description: "Exposed port of the proxyfied dashboard. Set to 0 to pick a random port", + args: { + name: "int", + }, }, { name: "--url", From cb8f0dc99561d39b5e84ee54c7cbc67232e619e4 Mon Sep 17 00:00:00 2001 From: yinchuandong Date: Tue, 15 Mar 2022 21:49:53 +1100 Subject: [PATCH 6/8] fix(terragrunt): terragrunt global options --- src/terragrunt.ts | 68 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/src/terragrunt.ts b/src/terragrunt.ts index 7383850f2a4b..669bfac6d8ba 100644 --- a/src/terragrunt.ts +++ b/src/terragrunt.ts @@ -25,6 +25,7 @@ const generalSubCommandOptions: Fig.Option[] = [ description: "Duration to retry a state lock. Default 0s", args: { name: "seconds", + default: "0", }, }, { @@ -47,6 +48,7 @@ const globalOptions: Fig.Option[] = [ name: "-help", description: "Show this help output, or the help for a specified subcommand", + isPersistent: true, }, { name: "-chdir", @@ -56,109 +58,147 @@ const globalOptions: Fig.Option[] = [ args: { template: "filepaths", }, + isPersistent: true, }, { name: "-version", description: "Show the current terragrunt version", + isPersistent: true, }, { name: "--terragrunt-config", description: "Path to the Terragrunt config file. Default is terragrunt.hcl", + isPersistent: true, }, { name: "--terragrunt-tfpath", description: "Path to the Terraform binary. Default is terraform (on PATH)", + isPersistent: true, }, { name: "--terragrunt-no-auto-init", description: "Don't automatically run 'terraform init' during other terragrunt commands. You must run 'terragrunt init' manually", + isPersistent: true, }, { name: "--terragrunt-non-interactive", description: "Assume 'yes' for all prompts", + isPersistent: true, }, { name: "--terragrunt-working-dir", description: "The path to the Terraform templates. Default is current directory", + isPersistent: true, }, { name: "--terragrunt-download-dir", description: "The path where to download Terraform code. Default is .terragrunt-cache in the working directory", + isPersistent: true, }, { name: "--terragrunt-source", description: "Download Terraform configurations from the specified source into a temporary folder, and run Terraform in that temporary folder", + isPersistent: true, }, { name: "--terragrunt-source-update", description: "Delete the contents of the temporary folder to clear out any old, cached source code before downloading new source code into it", + isPersistent: true, }, { name: "--terragrunt-iam-role", description: "Assume the specified IAM role before executing Terraform. Can also be set via the TERRAGRUNT_IAM_ROLE environment variable", + isPersistent: true, }, { name: "--terragrunt-ignore-dependency-errors", description: "*-all commands continue processing components even if a dependency fails", + isPersistent: true, }, { name: "--terragrunt-ignore-dependency-order", description: "*-all commands will be run disregarding the dependencie", + isPersistent: true, }, { name: "--terragrunt-ignore-external-dependencies", description: "*-all commands will not attempt to include external dependencies", + isPersistent: true, }, { name: "--terragrunt-include-external-dependencies", description: "*-all commands will include external dependencies", + isPersistent: true, }, { - name: "--terragrunt-parallelism ", + name: "--terragrunt-parallelism", description: "*-all commands parallelism set to at most N module", + args: { + name: "modules", + }, + isPersistent: true, }, { name: "--terragrunt-exclude-dir", description: "Unix-style glob of directories to exclude when running *-all commands", + isPersistent: true, }, { name: "--terragrunt-include-dir", description: "Unix-style glob of directories to include when running *-all command", + isPersistent: true, }, { name: "--terragrunt-check", description: "Enable check mode in the hclfmt command", + isPersistent: true, }, { name: "--terragrunt-hclfmt-file", description: "The path to a single terragrunt.hcl file that the hclfmt command should run on", + isPersistent: true, }, { name: "--terragrunt-override-attr", description: "A key=value attribute to override in a provider block as part of the aws-provider-patch command. May be specified multiple times", + isPersistent: true, }, { name: "--terragrunt-debug", description: "Write terragrunt-debug.tfvars to working folder to help root-cause issues", + isPersistent: true, }, { name: "--terragrunt-log-level", - description: - "Sets the logging level for Terragrunt. Supported levels: panic, fatal, error, warn (default), info, debug, trace", + description: "Sets the logging level for Terragrunt", + args: { + name: "level", + suggestions: [ + "panic", + "fatal", + "error", + "warn", + "info", + "debug", + "trace", + ], + default: "warn", + }, + isPersistent: true, }, ]; @@ -173,13 +213,11 @@ const mainCommands: Fig.Subcommand[] = [ "Opt to upgrade modules and plugins as part of their respective installation steps", }, ...generalSubCommandOptions, - ...globalOptions, ], }, { name: "validate", description: "Check whether the configuration is valid", - options: [...globalOptions], }, { name: "plan", @@ -203,6 +241,10 @@ const mainCommands: Fig.Subcommand[] = [ name: "-out", insertValue: "-out=", description: "The path to save the generated execution plan", + args: { + template: "filepaths", + suggestCurrentToken: true, + }, }, { name: "-parallelism", @@ -210,6 +252,7 @@ const mainCommands: Fig.Subcommand[] = [ "Limit the number of concurrent operation as terragrunt walks the graph. Defaults to 10", args: { name: "number", + default: "10", }, }, { @@ -232,14 +275,16 @@ const mainCommands: Fig.Subcommand[] = [ }, { name: "-target", - displayName: "-target=resource", + displayName: "-target=", description: "A Resource Address to target. This flag can be used multiple times", isRepeatable: true, + args: { + name: "resource", + }, }, { name: "-var", - insertValue: "-var {cursor}", description: "Set a variable in the terragrunt configuration. This flag can be set multiple times", isRepeatable: true, @@ -258,18 +303,15 @@ const mainCommands: Fig.Subcommand[] = [ }, }, ...generalSubCommandOptions, - ...globalOptions, ], }, { name: "apply", description: "Create or update infrastructure", - options: [...globalOptions], }, { name: "destroy", description: "Destroy previously-created infrastructure", - options: [...globalOptions], }, { name: "run-all", @@ -280,34 +322,28 @@ const mainCommands: Fig.Subcommand[] = [ name: "plan", description: "Display the plans of a ‘stack’ by running ‘terragrunt plan’ in each subfolder", - options: [...globalOptions], }, { name: "apply", description: "Apply a ‘stack’ by running ‘terragrunt apply’ in each subfolder", - options: [...globalOptions], }, { name: "output", description: "Display the outputs of a ‘stack’ by running ‘terragrunt output’ in each subfolder", - options: [...globalOptions], }, { name: "destroy", description: "Destroy a ‘stack’ by running ‘terragrunt destroy’ in each subfolder", - options: [...globalOptions], }, { name: "validate", description: "Validate a ‘stack’ by running ‘terragrunt destroy’ in each subfolder", - options: [...globalOptions], }, ], - options: [...globalOptions], }, ]; From c73caef3b3b6ffe69aad09ee534ee3ded2fd159c Mon Sep 17 00:00:00 2001 From: yinchuandong Date: Wed, 16 Mar 2022 08:52:00 +1100 Subject: [PATCH 7/8] feat(terragrunt): add args for global options --- src/terragrunt.ts | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/src/terragrunt.ts b/src/terragrunt.ts index 669bfac6d8ba..c837177cd2ce 100644 --- a/src/terragrunt.ts +++ b/src/terragrunt.ts @@ -50,16 +50,6 @@ const globalOptions: Fig.Option[] = [ "Show this help output, or the help for a specified subcommand", isPersistent: true, }, - { - name: "-chdir", - description: - "Switch to a different working directory before executing the given subcommand", - insertValue: "-chdir=", - args: { - template: "filepaths", - }, - isPersistent: true, - }, { name: "-version", description: "Show the current terragrunt version", @@ -69,11 +59,17 @@ const globalOptions: Fig.Option[] = [ name: "--terragrunt-config", description: "Path to the Terragrunt config file. Default is terragrunt.hcl", + args: { + template: "filepaths", + }, isPersistent: true, }, { name: "--terragrunt-tfpath", description: "Path to the Terraform binary. Default is terraform (on PATH)", + args: { + template: "filepaths", + }, isPersistent: true, }, { @@ -91,18 +87,27 @@ const globalOptions: Fig.Option[] = [ name: "--terragrunt-working-dir", description: "The path to the Terraform templates. Default is current directory", + args: { + template: "filepaths", + }, isPersistent: true, }, { name: "--terragrunt-download-dir", description: "The path where to download Terraform code. Default is .terragrunt-cache in the working directory", + args: { + template: "filepaths", + }, isPersistent: true, }, { name: "--terragrunt-source", description: "Download Terraform configurations from the specified source into a temporary folder, and run Terraform in that temporary folder", + args: { + template: "filepaths", + }, isPersistent: true, }, { @@ -115,6 +120,10 @@ const globalOptions: Fig.Option[] = [ name: "--terragrunt-iam-role", description: "Assume the specified IAM role before executing Terraform. Can also be set via the TERRAGRUNT_IAM_ROLE environment variable", + args: { + name: "iam-role-arn", + description: "AWS IAM role ARN", + }, isPersistent: true, }, { @@ -151,12 +160,18 @@ const globalOptions: Fig.Option[] = [ name: "--terragrunt-exclude-dir", description: "Unix-style glob of directories to exclude when running *-all commands", + args: { + template: "filepaths", + }, isPersistent: true, }, { name: "--terragrunt-include-dir", description: "Unix-style glob of directories to include when running *-all command", + args: { + template: "filepaths", + }, isPersistent: true, }, { @@ -168,12 +183,19 @@ const globalOptions: Fig.Option[] = [ name: "--terragrunt-hclfmt-file", description: "The path to a single terragrunt.hcl file that the hclfmt command should run on", + args: { + template: "filepaths", + }, isPersistent: true, }, { name: "--terragrunt-override-attr", description: "A key=value attribute to override in a provider block as part of the aws-provider-patch command. May be specified multiple times", + args: { + name: "attr=value", + description: "ATTR=VALUE", + }, isPersistent: true, }, { From defda7eb00f2d7deeecd47ff4f94efcdfdafe536 Mon Sep 17 00:00:00 2001 From: yinchuandong Date: Wed, 16 Mar 2022 09:07:56 +1100 Subject: [PATCH 8/8] feat(terragrunt): import subcommands from terraform spec --- src/terragrunt.ts | 161 ++-------------------------------------------- 1 file changed, 6 insertions(+), 155 deletions(-) diff --git a/src/terragrunt.ts b/src/terragrunt.ts index c837177cd2ce..628fa2687ce3 100644 --- a/src/terragrunt.ts +++ b/src/terragrunt.ts @@ -1,47 +1,4 @@ -const generalSubCommandOptions: Fig.Option[] = [ - { - name: "-lock", - insertValue: "-lock=", - description: - "Lock the state file when locking is supported. Defaults to true", - args: { - name: "true or false", - suggestions: ["true", "false"], - }, - }, - { - name: "-force", - insertValue: "-force=", - description: - "Delete the workspace even if its state is not empty. Defaults to false", - args: { - name: "true or false", - suggestions: ["true", "false"], - }, - }, - { - name: "-lock-timeout", - insertValue: "-lock-timeout=", - description: "Duration to retry a state lock. Default 0s", - args: { - name: "seconds", - default: "0", - }, - }, - { - name: "-input", - insertValue: "-input=", - description: "Ask for input for variables if not directly set", - args: { - name: "true or false", - suggestions: ["true", "false"], - }, - }, - { - name: "-no-color", - description: "Disables output with coloring", - }, -]; +import terraform from "./terraform"; const globalOptions: Fig.Option[] = [ { @@ -225,116 +182,6 @@ const globalOptions: Fig.Option[] = [ ]; const mainCommands: Fig.Subcommand[] = [ - { - name: "init", - description: "Prepare your working directory for other commands", - options: [ - { - name: "-upgrade", - description: - "Opt to upgrade modules and plugins as part of their respective installation steps", - }, - ...generalSubCommandOptions, - ], - }, - { - name: "validate", - description: "Check whether the configuration is valid", - }, - { - name: "plan", - description: "Show changes required by the current configuration", - options: [ - { - name: "-compact-warnings", - description: - "If terragrunt produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages", - }, - { - name: "-destroy", - description: - "If set, generates a plan to destroy all the known resources", - }, - { - name: "-detailed-exitcode", - description: "Return a detailed exit code when the command exits", - }, - { - name: "-out", - insertValue: "-out=", - description: "The path to save the generated execution plan", - args: { - template: "filepaths", - suggestCurrentToken: true, - }, - }, - { - name: "-parallelism", - description: - "Limit the number of concurrent operation as terragrunt walks the graph. Defaults to 10", - args: { - name: "number", - default: "10", - }, - }, - { - name: "-refresh", - insertValue: "-refresh=", - description: "Update the state prior to checking for differences", - args: { - name: "true or false", - suggestions: ["true", "false"], - }, - }, - { - name: "-state", - insertValue: "-state=", - description: - "Path to the state file. Defaults to 'terragrunt.tfstate'. Ignored when remote state is used", - args: { - template: "filepaths", - }, - }, - { - name: "-target", - displayName: "-target=", - description: - "A Resource Address to target. This flag can be used multiple times", - isRepeatable: true, - args: { - name: "resource", - }, - }, - { - name: "-var", - description: - "Set a variable in the terragrunt configuration. This flag can be set multiple times", - isRepeatable: true, - args: { - name: "foo=bar", - }, - }, - - { - name: "-var-file", - insertValue: "-var-file=", - description: - "Set variables in the terragrunt configuration from a variable file", - args: { - template: "filepaths", - }, - }, - ...generalSubCommandOptions, - ], - }, - { - name: "apply", - description: "Create or update infrastructure", - }, - { - name: "destroy", - description: "Destroy previously-created infrastructure", - }, { name: "run-all", description: @@ -416,7 +263,11 @@ const completionSpec: Fig.Spec = { parserDirectives: { flagsArePosixNoncompliant: true, }, - subcommands: [...mainCommands, ...otherCommands], + subcommands: [ + ...(terraform as Fig.Subcommand).subcommands, + ...mainCommands, + ...otherCommands, + ], }; export default completionSpec;