Skip to content

Commit

Permalink
gcloud: fix bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Dec 24, 2024
1 parent ce79290 commit 5aee54e
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 37 deletions.
8 changes: 8 additions & 0 deletions .docker/gcloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
gcloud:
build:
context: gcloud
image: ghcr.io/carapace-sh/carapace-bin:gcloud
hostname: carapace-bin:gcloud
volumes:
- '..:/carapace-bin:ro'
10 changes: 10 additions & 0 deletions .docker/gcloud/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM gcr.io/google.com/cloudsdktool/google-cloud-cli:stable

RUN apt-get update && apt-get install -y curl
RUN curl -so - https://dl.elv.sh/linux-amd64/elvish-HEAD.tar.gz | tar -xzvC /usr/local/bin

RUN mkdir -p ~/.config/elvish \
&& echo "set paths = [ /carapace-bin/cmd/carapace \$@paths ]\neval (carapace _carapace|slurp)" > ~/.config/elvish/rc.elv
ENV PATH="/carapace-bin/cmd/carapace:$PATH"

CMD ["elvish"]
66 changes: 34 additions & 32 deletions cmd/carapace-generate/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,40 +177,42 @@ func macros() {
`bridge "github.com/carapace-sh/carapace-bridge/pkg/actions/bridge"`: true,
}
macros := []string{
`"bridge.Argcomplete": spec.MacroV(bridge.ActionArgcomplete),`,
`"bridge.Bash": spec.MacroV(bridge.ActionBash),`,
`"bridge.Carapace": spec.MacroV(bridge.ActionCarapace),`,
`"bridge.CarapaceBin": spec.MacroV(bridge.ActionCarapaceBin),`,
`"bridge.Clap": spec.MacroV(bridge.ActionClap),`,
`"bridge.Click": spec.MacroV(bridge.ActionClick),`,
`"bridge.Cobra": spec.MacroV(bridge.ActionCobra),`,
`"bridge.Complete": spec.MacroV(bridge.ActionComplete),`,
`"bridge.Fish": spec.MacroV(bridge.ActionFish),`,
`"bridge.Inshellisense": spec.MacroV(bridge.ActionInshellisense),`,
`"bridge.Kingpin": spec.MacroV(bridge.ActionKingpin),`,
`"bridge.Macro": spec.MacroV(bridge.ActionMacro),`,
`"bridge.Powershell": spec.MacroV(bridge.ActionPowershell),`,
`"bridge.Urfavecli": spec.MacroV(bridge.ActionUrfavecli),`,
`"bridge.Yargs": spec.MacroV(bridge.ActionYargs),`,
`"bridge.Zsh": spec.MacroV(bridge.ActionZsh),`,
`"bridge.Argcomplete": spec.MacroV(bridge.ActionArgcomplete),`,
`"bridge.ArgcompleteLegacy": spec.MacroV(bridge.ActionArgcompleteLegacy), //lint:ignore SA1019 gcloud uses an old argcomplete version`,
`"bridge.Bash": spec.MacroV(bridge.ActionBash),`,
`"bridge.Carapace": spec.MacroV(bridge.ActionCarapace),`,
`"bridge.CarapaceBin": spec.MacroV(bridge.ActionCarapaceBin),`,
`"bridge.Clap": spec.MacroV(bridge.ActionClap),`,
`"bridge.Click": spec.MacroV(bridge.ActionClick),`,
`"bridge.Cobra": spec.MacroV(bridge.ActionCobra),`,
`"bridge.Complete": spec.MacroV(bridge.ActionComplete),`,
`"bridge.Fish": spec.MacroV(bridge.ActionFish),`,
`"bridge.Inshellisense": spec.MacroV(bridge.ActionInshellisense),`,
`"bridge.Kingpin": spec.MacroV(bridge.ActionKingpin),`,
`"bridge.Macro": spec.MacroV(bridge.ActionMacro),`,
`"bridge.Powershell": spec.MacroV(bridge.ActionPowershell),`,
`"bridge.Urfavecli": spec.MacroV(bridge.ActionUrfavecli),`,
`"bridge.Yargs": spec.MacroV(bridge.ActionYargs),`,
`"bridge.Zsh": spec.MacroV(bridge.ActionZsh),`,
}
descriptions := map[string]string{
"bridge.Argcomplete": "bridges https://github.com/kislyuk/argcomplete",
"bridge.Bash": "bridges https://www.gnu.org/software/bash/",
"bridge.Carapace": "bridges https://github.com/carapace-sh/carapace",
"bridge.CarapaceBin": "bridges https://github.com/carapace-sh/carapace-bin",
"bridge.Clap": "bridges https://github.com/clap-rs/clap",
"bridge.Click": "bridges https://github.com/pallets/click",
"bridge.Cobra": "bridges https://github.com/spf13/cobra",
"bridge.Complete": "bridges https://github.com/posener/complete",
"bridge.Fish": "bridges https://fishshell.com/",
"bridge.Inshellisense": "bridges https://github.com/microsoft/inshellisense",
"bridge.Kingpin": "bridges https://github.com/alecthomas/kingpin",
"bridge.Macro": "bridges macros exposed with https://github.com/carapace-sh/carapace-spec",
"bridge.Powershell": "bridges https://microsoft.com/powershell",
"bridge.Urfavecli": "bridges https://github.com/urfave/cli",
"bridge.Yargs": "bridges https://github.com/yargs/yargs",
"bridge.Zsh": "bridges https://www.zsh.org/",
"bridge.Argcomplete": "bridges https://github.com/kislyuk/argcomplete",
"bridge.ArgcompleteLegacy": "bridges https://github.com/kislyuk/argcomplete",
"bridge.Bash": "bridges https://www.gnu.org/software/bash/",
"bridge.Carapace": "bridges https://github.com/carapace-sh/carapace",
"bridge.CarapaceBin": "bridges https://github.com/carapace-sh/carapace-bin",
"bridge.Clap": "bridges https://github.com/clap-rs/clap",
"bridge.Click": "bridges https://github.com/pallets/click",
"bridge.Cobra": "bridges https://github.com/spf13/cobra",
"bridge.Complete": "bridges https://github.com/posener/complete",
"bridge.Fish": "bridges https://fishshell.com/",
"bridge.Inshellisense": "bridges https://github.com/microsoft/inshellisense",
"bridge.Kingpin": "bridges https://github.com/alecthomas/kingpin",
"bridge.Macro": "bridges macros exposed with https://github.com/carapace-sh/carapace-spec",
"bridge.Powershell": "bridges https://microsoft.com/powershell",
"bridge.Urfavecli": "bridges https://github.com/urfave/cli",
"bridge.Yargs": "bridges https://github.com/yargs/yargs",
"bridge.Zsh": "bridges https://www.zsh.org/",
}

r := regexp.MustCompile(`^func Action(?P<name>[^(]+)\((?P<arg>[^(]*)\) carapace.Action {$`)
Expand Down
5 changes: 3 additions & 2 deletions completers/gcloud_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ func init() {
// TODO patch user@instance and --flag=optarg as in gcloud completion script

if c.Value == "-" {
return carapace.ActionValues("--").NoSpace() // seems shorthand flags aren't completed anyway so expand to longhand first
c.Value = "--" // seems shorthand flags aren't completed anyway so expand to longhand first
}
c.Setenv("CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK", "1")
return bridge.ActionArgcomplete("gcloud").Invoke(c).ToA()
//lint:ignore SA1019 gcloud uses an old argcomplete version
return bridge.ActionArgcompleteLegacy("gcloud").Invoke(c).ToA()
}),
)
}
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ include:
- .docker/carapace.yaml
# tools
- .docker/bloop.yaml
- .docker/gcloud.yaml
- .docker/nix.yaml
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23.1

require (
github.com/carapace-sh/carapace v1.5.0
github.com/carapace-sh/carapace-bridge v1.2.1
github.com/carapace-sh/carapace-bridge v1.2.2
github.com/carapace-sh/carapace-selfupdate v0.0.8
github.com/carapace-sh/carapace-shlex v1.0.1
github.com/carapace-sh/carapace-spec v1.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/carapace-sh/carapace v1.5.0 h1:rjNMTo5sY3YybMKbzEuaM19HEG6JXhvCTOrioV0QUHY=
github.com/carapace-sh/carapace v1.5.0/go.mod h1:djegtVDi/3duSAqZNU+/nCq7XtDRMRZUb5bW0O/HnEs=
github.com/carapace-sh/carapace-bridge v1.2.1 h1:OtCA4/8+0zTpVDusqF4p0hzYjawMTlZBl37u6ImIjdo=
github.com/carapace-sh/carapace-bridge v1.2.1/go.mod h1:HpN3iEdCmQtAD1pd/qHEnWmAF719CeNyJrY8FJ5/E4o=
github.com/carapace-sh/carapace-bridge v1.2.2 h1:Zlzw7BajF4iHAFBClCYcptEG+7+F324dFyiGzGiU/kw=
github.com/carapace-sh/carapace-bridge v1.2.2/go.mod h1:HpN3iEdCmQtAD1pd/qHEnWmAF719CeNyJrY8FJ5/E4o=
github.com/carapace-sh/carapace-pflag v1.0.0 h1:uJMhl+vwEM/Eb0UdxZUuv4jo4rUAyPijkRGP5gfCuCE=
github.com/carapace-sh/carapace-pflag v1.0.0/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/carapace-sh/carapace-selfupdate v0.0.8 h1:gvZCzPw3MmEQpN+KwLThod4mXKl0kx/p+QVHIs0L4dM=
Expand Down

0 comments on commit 5aee54e

Please sign in to comment.