From deb9fb2f2457517307d4b4486c724e2c14d6aada Mon Sep 17 00:00:00 2001 From: rsteube Date: Wed, 11 Dec 2024 23:30:42 +0100 Subject: [PATCH] tmp --- completers/bru_completer/cmd/run.go | 2 +- completers/cargo-watch_completer/cmd/root.go | 2 +- completers/circleci_completer/cmd/local_execute.go | 2 +- completers/codecov_completer/cmd/root.go | 2 +- completers/docker-compose_completer/cmd/exec.go | 2 +- completers/docker-compose_completer/cmd/run.go | 2 +- completers/docker_completer/cmd/container_create.go | 2 +- completers/docker_completer/cmd/container_exec.go | 2 +- completers/docker_completer/cmd/container_run.go | 2 +- completers/docker_completer/cmd/exec.go | 2 +- completers/docker_completer/cmd/service_create.go | 2 +- completers/faas-cli_completer/cmd/deploy.go | 2 +- completers/faas-cli_completer/cmd/store_deploy.go | 2 +- completers/faas-cli_completer/cmd/up.go | 2 +- completers/flatpak_completer/cmd/build.go | 2 +- completers/flatpak_completer/cmd/buildFinish.go | 2 +- completers/flatpak_completer/cmd/override.go | 2 +- completers/flatpak_completer/cmd/run.go | 2 +- completers/kubectl_completer/cmd/debug.go | 2 +- completers/kubectl_completer/cmd/kustomize.go | 2 +- completers/kubectl_completer/cmd/run.go | 2 +- completers/kubectl_completer/cmd/set_env.go | 2 +- completers/qmk_completer/cmd/compile.go | 2 +- completers/qmk_completer/cmd/flash.go | 2 +- completers/run0_completer/cmd/root.go | 2 +- completers/set-env_completer/cmd/root.go | 2 +- completers/vercel_completer/cmd/root.go | 4 ++-- completers/volta_completer/cmd/run.go | 2 +- pkg/actions/env/env.go | 10 +++++----- 29 files changed, 34 insertions(+), 34 deletions(-) diff --git a/completers/bru_completer/cmd/run.go b/completers/bru_completer/cmd/run.go index 233777cba..bd4189122 100644 --- a/completers/bru_completer/cmd/run.go +++ b/completers/bru_completer/cmd/run.go @@ -30,7 +30,7 @@ func init() { carapace.Gen(runCmd).FlagCompletion(carapace.ActionMap{ "cacert": carapace.ActionFiles(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "env-var": carapace.ActionValues(), // TODO "format": carapace.ActionValues("json", "junit", "html"), "output": carapace.ActionFiles(), diff --git a/completers/cargo-watch_completer/cmd/root.go b/completers/cargo-watch_completer/cmd/root.go index 28fb7db4d..4ed316f1a 100644 --- a/completers/cargo-watch_completer/cmd/root.go +++ b/completers/cargo-watch_completer/cmd/root.go @@ -56,7 +56,7 @@ func init() { carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ "exec": bridge.ActionCarapaceBin("cargo").Split(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "features": cargo.ActionFeatures("").UniqueList(","), "shell": bridge.ActionCarapaceBin().SplitP(), "use-shell": os.ActionShells(), diff --git a/completers/circleci_completer/cmd/local_execute.go b/completers/circleci_completer/cmd/local_execute.go index 860a8666e..4532e1400 100644 --- a/completers/circleci_completer/cmd/local_execute.go +++ b/completers/circleci_completer/cmd/local_execute.go @@ -39,6 +39,6 @@ func init() { }), "checkout-key": carapace.ActionFiles(), "config": carapace.ActionFiles(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), }) } diff --git a/completers/codecov_completer/cmd/root.go b/completers/codecov_completer/cmd/root.go index e0eb03980..54065370a 100644 --- a/completers/codecov_completer/cmd/root.go +++ b/completers/codecov_completer/cmd/root.go @@ -50,7 +50,7 @@ func init() { // TODO rootDir for git actions "branch": git.ActionRefs(git.RefOption{LocalBranches: true}), "dir": carapace.ActionDirectories(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "file": carapace.ActionFiles(), "rootDir": carapace.ActionDirectories(), "tag": git.ActionRefs(git.RefOption{Tags: true}), diff --git a/completers/docker-compose_completer/cmd/exec.go b/completers/docker-compose_completer/cmd/exec.go index 53b124e43..31059526c 100644 --- a/completers/docker-compose_completer/cmd/exec.go +++ b/completers/docker-compose_completer/cmd/exec.go @@ -32,7 +32,7 @@ func init() { // TODO workdir completion // TODO index carapace.Gen(execCmd).FlagCompletion(carapace.ActionMap{ - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "user": carapace.ActionCallback(func(c carapace.Context) carapace.Action { if len(c.Args) > 0 { if index, err := execCmd.Flags().GetInt("index"); err != nil { diff --git a/completers/docker-compose_completer/cmd/run.go b/completers/docker-compose_completer/cmd/run.go index 6c2676957..ed34c5f79 100644 --- a/completers/docker-compose_completer/cmd/run.go +++ b/completers/docker-compose_completer/cmd/run.go @@ -42,7 +42,7 @@ func init() { // TODO flag completion carapace.Gen(runCmd).FlagCompletion(carapace.ActionMap{ - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "volume": action.ActionVolumes(runCmd), }) diff --git a/completers/docker_completer/cmd/container_create.go b/completers/docker_completer/cmd/container_create.go index 896bb5deb..1cd008283 100644 --- a/completers/docker_completer/cmd/container_create.go +++ b/completers/docker_completer/cmd/container_create.go @@ -127,7 +127,7 @@ func init() { "cidfile": carapace.ActionFiles(), "cpu-shares": carapace.ActionValues("0", "10", "100", "200", "500", "800", "1000"), "device": carapace.ActionFiles(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "env-file": carapace.ActionFiles(), "group-add": os.ActionGroups(), "isolation": carapace.ActionValues("default", "hyperv", "process"), diff --git a/completers/docker_completer/cmd/container_exec.go b/completers/docker_completer/cmd/container_exec.go index cdd85f3cc..dc861fe3f 100644 --- a/completers/docker_completer/cmd/container_exec.go +++ b/completers/docker_completer/cmd/container_exec.go @@ -30,7 +30,7 @@ func init() { carapace.Gen(container_execCmd).FlagCompletion(carapace.ActionMap{ "detach-keys": docker.ActionDetachKeys(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "env-file": carapace.ActionFiles(), "user": os.ActionUserGroup(), }) diff --git a/completers/docker_completer/cmd/container_run.go b/completers/docker_completer/cmd/container_run.go index 33bc97b0e..3675542e8 100644 --- a/completers/docker_completer/cmd/container_run.go +++ b/completers/docker_completer/cmd/container_run.go @@ -131,7 +131,7 @@ func init() { "cpu-shares": carapace.ActionValues("0", "10", "100", "200", "500", "800", "1000"), "detach-keys": docker.ActionDetachKeys(), "device": carapace.ActionFiles(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "env-file": carapace.ActionFiles(), "group-add": os.ActionGroups(), "isolation": carapace.ActionValues("default", "hyperv", "process"), diff --git a/completers/docker_completer/cmd/exec.go b/completers/docker_completer/cmd/exec.go index d93a350f6..a6dbdde79 100644 --- a/completers/docker_completer/cmd/exec.go +++ b/completers/docker_completer/cmd/exec.go @@ -30,7 +30,7 @@ func init() { carapace.Gen(execCmd).FlagCompletion(carapace.ActionMap{ "detach-keys": docker.ActionDetachKeys(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "env-file": carapace.ActionFiles(), }) } diff --git a/completers/docker_completer/cmd/service_create.go b/completers/docker_completer/cmd/service_create.go index 30c9c9ce8..850439fed 100644 --- a/completers/docker_completer/cmd/service_create.go +++ b/completers/docker_completer/cmd/service_create.go @@ -96,7 +96,7 @@ func init() { carapace.Gen(service_createCmd).FlagCompletion(carapace.ActionMap{ "endpoint-mode": carapace.ActionValues("vip", "dnsrr"), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "env-file": carapace.ActionFiles(), "group": os.ActionGroups(), "isolation": carapace.ActionValues("default", "hyperv", "process"), diff --git a/completers/faas-cli_completer/cmd/deploy.go b/completers/faas-cli_completer/cmd/deploy.go index 447740e0d..726c669a4 100644 --- a/completers/faas-cli_completer/cmd/deploy.go +++ b/completers/faas-cli_completer/cmd/deploy.go @@ -40,7 +40,7 @@ func init() { rootCmd.AddCommand(deployCmd) carapace.Gen(deployCmd).FlagCompletion(carapace.ActionMap{ - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "handler": carapace.ActionDirectories(), "lang": action.ActionLanguageTemplates(), "namespace": action.ActionNamespaces(), diff --git a/completers/faas-cli_completer/cmd/store_deploy.go b/completers/faas-cli_completer/cmd/store_deploy.go index bf99f77c6..4104990e2 100644 --- a/completers/faas-cli_completer/cmd/store_deploy.go +++ b/completers/faas-cli_completer/cmd/store_deploy.go @@ -31,7 +31,7 @@ func init() { storeCmd.AddCommand(store_deployCmd) carapace.Gen(store_deployCmd).FlagCompletion(carapace.ActionMap{ - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "namespace": action.ActionNamespaces(), }) diff --git a/completers/faas-cli_completer/cmd/up.go b/completers/faas-cli_completer/cmd/up.go index de28e0ffc..c3eef1974 100644 --- a/completers/faas-cli_completer/cmd/up.go +++ b/completers/faas-cli_completer/cmd/up.go @@ -52,7 +52,7 @@ func init() { carapace.Gen(upCmd).FlagCompletion(carapace.ActionMap{ "copy-extra": carapace.ActionDirectories(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "handler": carapace.ActionDirectories(), "lang": action.ActionLanguageTemplates(), "name": action.ActionFunctions(), diff --git a/completers/flatpak_completer/cmd/build.go b/completers/flatpak_completer/cmd/build.go index 2426b1a2f..e7e2eb100 100644 --- a/completers/flatpak_completer/cmd/build.go +++ b/completers/flatpak_completer/cmd/build.go @@ -62,7 +62,7 @@ func init() { "build-dir": carapace.ActionDirectories(), // "device": carapace.ActionValues(), // "disallow": carapace.ActionValues(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), // "env-fd": carapace.ActionValues(), // "filesystem": carapace.ActionValues(), // "metadata": carapace.ActionValues(), diff --git a/completers/flatpak_completer/cmd/buildFinish.go b/completers/flatpak_completer/cmd/buildFinish.go index 73a144b15..a97ed6829 100644 --- a/completers/flatpak_completer/cmd/buildFinish.go +++ b/completers/flatpak_completer/cmd/buildFinish.go @@ -62,7 +62,7 @@ func init() { // "command": carapace.ActionValues(). // "device": carapace.ActionValues(). // "disallow": carapace.ActionValues(). - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), // "env-fd": carapace.ActionValues(). // "extension": carapace.ActionValues(). // "extension-priority": carapace.ActionValues(). diff --git a/completers/flatpak_completer/cmd/override.go b/completers/flatpak_completer/cmd/override.go index 89111685a..3837fcc63 100644 --- a/completers/flatpak_completer/cmd/override.go +++ b/completers/flatpak_completer/cmd/override.go @@ -56,7 +56,7 @@ func init() { // "allow": carapace.ActionValues(), // "device": carapace.ActionValues(), // "disallow": carapace.ActionValues(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), // "env-fd": carapace.ActionValues(), // "filesystem": carapace.ActionValues(), // "installation": carapace.ActionValues(), diff --git a/completers/flatpak_completer/cmd/run.go b/completers/flatpak_completer/cmd/run.go index 53d0c32c0..8e4767df2 100644 --- a/completers/flatpak_completer/cmd/run.go +++ b/completers/flatpak_completer/cmd/run.go @@ -86,7 +86,7 @@ func init() { // "cwd": carapace.ActionValues(), // "device": carapace.ActionValues(), // "disallow": carapace.ActionValues(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), // "env-fd": carapace.ActionValues(), // "filesystem": carapace.ActionValues(), // "installation": carapace.ActionValues(), diff --git a/completers/kubectl_completer/cmd/debug.go b/completers/kubectl_completer/cmd/debug.go index a42561494..ef24f2454 100644 --- a/completers/kubectl_completer/cmd/debug.go +++ b/completers/kubectl_completer/cmd/debug.go @@ -44,7 +44,7 @@ func init() { // TODO flag completion carapace.Gen(debugCmd).FlagCompletion(carapace.ActionMap{ - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "profile": carapace.ActionValues("legacy", "general", "baseline", "netadmin", "restricted", "sysadmin"), }) } diff --git a/completers/kubectl_completer/cmd/kustomize.go b/completers/kubectl_completer/cmd/kustomize.go index 03505f022..2e1743dac 100644 --- a/completers/kubectl_completer/cmd/kustomize.go +++ b/completers/kubectl_completer/cmd/kustomize.go @@ -35,7 +35,7 @@ func init() { rootCmd.AddCommand(kustomizeCmd) carapace.Gen(kustomizeCmd).FlagCompletion(carapace.ActionMap{ - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "output": carapace.ActionFiles(), "reorder": carapace.ActionValues("legacy", "none"), }) diff --git a/completers/kubectl_completer/cmd/run.go b/completers/kubectl_completer/cmd/run.go index 731e54355..ab1aeb70c 100644 --- a/completers/kubectl_completer/cmd/run.go +++ b/completers/kubectl_completer/cmd/run.go @@ -60,7 +60,7 @@ func init() { carapace.Gen(runCmd).FlagCompletion(carapace.ActionMap{ "dry-run": kubectl.ActionDryRunModes(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "image-pull-policy": carapace.ActionValues("Never", "Always", "IfNotPresent"), "output": kubectl.ActionOutputFormats(), "restart": carapace.ActionValues("Always", "OnFailure", "Never"), diff --git a/completers/kubectl_completer/cmd/set_env.go b/completers/kubectl_completer/cmd/set_env.go index 6c6770027..202f1848f 100644 --- a/completers/kubectl_completer/cmd/set_env.go +++ b/completers/kubectl_completer/cmd/set_env.go @@ -41,7 +41,7 @@ func init() { carapace.Gen(set_envCmd).FlagCompletion(carapace.ActionMap{ "dry-run": kubectl.ActionDryRunModes(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "filename": carapace.ActionFiles(), "from": kubectl.ActionApiResourceResources(kubectl.ApiResourceResourcesOpts{}), "output": kubectl.ActionOutputFormats(), diff --git a/completers/qmk_completer/cmd/compile.go b/completers/qmk_completer/cmd/compile.go index d0d4020ae..af7b4d95f 100644 --- a/completers/qmk_completer/cmd/compile.go +++ b/completers/qmk_completer/cmd/compile.go @@ -26,7 +26,7 @@ func init() { rootCmd.AddCommand(compileCmd) carapace.Gen(compileCmd).FlagCompletion(carapace.ActionMap{ - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "keyboard": carapace.ActionCallback(func(c carapace.Context) carapace.Action { return action.ActionKeyboards().Invoke(c).ToMultiPartsA("/") }), diff --git a/completers/qmk_completer/cmd/flash.go b/completers/qmk_completer/cmd/flash.go index 0a0bcd100..b6c6fdcde 100644 --- a/completers/qmk_completer/cmd/flash.go +++ b/completers/qmk_completer/cmd/flash.go @@ -29,7 +29,7 @@ func init() { carapace.Gen(flashCmd).FlagCompletion(carapace.ActionMap{ "bootloader": action.ActionBootloaders(), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "keyboard": carapace.ActionCallback(func(c carapace.Context) carapace.Action { return action.ActionKeyboards().Invoke(c).ToMultiPartsA("/") }), diff --git a/completers/run0_completer/cmd/root.go b/completers/run0_completer/cmd/root.go index 21db0b950..4bb1ae231 100644 --- a/completers/run0_completer/cmd/root.go +++ b/completers/run0_completer/cmd/root.go @@ -45,7 +45,7 @@ func init() { "background": color.ActionAnsiBackgroundColors(false), "chdir": carapace.ActionDirectories(), "group": os.ActionGroups(), - "setenv": env.ActionConfigs(env.ConfigOpts{}.Default()), + "setenv": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "user": os.ActionUsers(), }) diff --git a/completers/set-env_completer/cmd/root.go b/completers/set-env_completer/cmd/root.go index 47d1da50c..e219b07cf 100644 --- a/completers/set-env_completer/cmd/root.go +++ b/completers/set-env_completer/cmd/root.go @@ -21,6 +21,6 @@ func init() { carapace.Gen(rootCmd).Standalone() carapace.Gen(rootCmd).PositionalAnyCompletion( - env.ActionConfigs(env.ConfigOpts{Attached: false, User: true}), + env.ActionSetEnvs(env.SetEnvOpts{Attached: false, User: true}), ) } diff --git a/completers/vercel_completer/cmd/root.go b/completers/vercel_completer/cmd/root.go index a7e111cbe..86497df68 100644 --- a/completers/vercel_completer/cmd/root.go +++ b/completers/vercel_completer/cmd/root.go @@ -41,8 +41,8 @@ func init() { rootCmd.PersistentFlags().BoolP("help", "h", false, "Output usage information") carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ - "build-env": env.ActionConfigs(env.ConfigOpts{}.Default()), - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "build-env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), "global-config": carapace.ActionDirectories(), "local-config": carapace.ActionFiles(), "regions": action.ActionRegions().UniqueList(","), diff --git a/completers/volta_completer/cmd/run.go b/completers/volta_completer/cmd/run.go index fafe0ecfe..a1c6cf1b2 100644 --- a/completers/volta_completer/cmd/run.go +++ b/completers/volta_completer/cmd/run.go @@ -27,6 +27,6 @@ func init() { rootCmd.AddCommand(runCmd) carapace.Gen(runCmd).FlagCompletion(carapace.ActionMap{ - "env": env.ActionConfigs(env.ConfigOpts{}.Default()), + "env": env.ActionSetEnvs(env.SetEnvOpts{}.Default()), }) } diff --git a/pkg/actions/env/env.go b/pkg/actions/env/env.go index d0643700f..34794dcaa 100644 --- a/pkg/actions/env/env.go +++ b/pkg/actions/env/env.go @@ -224,21 +224,21 @@ func loadCustomVariables(file string) (*variables, error) { return &v, nil } -type ConfigOpts struct { - // complete values attached (`KEY=VALUE`) or positional (`KEY VALUE`) +type SetEnvOpts struct { + // complete values attached (`KEY[=VALUE]`) or positional (`KEY VALUE`) Attached bool // include user defined variables User bool // TODO } -func (o ConfigOpts) Default() ConfigOpts { +func (o SetEnvOpts) Default() SetEnvOpts { o.Attached = true o.User = true return o } -// ActionConfigs completes environment variable configurations -func ActionConfigs(opts ConfigOpts) carapace.Action { +// ActionSetEnvs completes environment variables setters +func ActionSetEnvs(opts SetEnvOpts) carapace.Action { return carapace.ActionCallback(func(c carapace.Context) carapace.Action { keysAction := carapace.Batch( carapace.ActionCallback(func(c carapace.Context) carapace.Action {