2020-10-17 20:34:35 +02:00
2020-10-17 20:34:35 +02:00
2020-10-15 17:47:56 +02:00
2020-10-17 20:34:35 +02:00
2020-10-17 20:34:35 +02:00
2020-10-11 23:15:22 +02:00
2020-10-11 23:15:22 +02:00
2020-10-16 12:22:08 +02:00
2020-10-08 01:02:28 +02:00
2020-10-08 12:58:55 +02:00
2020-04-20 22:58:56 +02:00
2020-10-09 11:48:43 +02:00
2020-10-17 20:34:35 +02:00

carapace-bin

CircleCI PkgGoDev GoReportCard

Multi-shell multi-command argument completer based on rsteube/carapace.

asciicast

Supported shells:

Status

A major part of the completers has been generated from help pages so there will be some quirks here and there. Also completion depends on what rsteube/carapace is capable of so far.

Example

docker-compose run --rm build
docker-compose run --rm [bash|elvish|fish|oil|powershell|xonsh|zsh]
[ln|mkdir|chown...] <TAB>

Build

cd cmd/carapace && go generate ./... && go build -ldflags="-s -w"

For smallest file size (300kb instead of 6mb) use gccgo with flags "-s -w" and upx (upx slows down invocation but should still be fast enough).

Completers can also be built separately:

cd completers/ln_completer && go build -ldflags="-s -w"
./ln_completer _carapace [bash|elvish|fish|oil|powershell|xonsh|zsh]

Generate completion

Ensure carapace is added to PATH.

  • completion for carapace itself
carapace _carapace [bash|elvish|fish|oil|powershell|xonsh|zsh]
  • completion for commands
carapace [ln|mkdir|...] [bash|elvish|fish|oil|powershell|xonsh|zsh]
  • list completions
carapace --list

If the shell is left out carapace will try to determine it by the parent process name.

Creating completers

caraparse is a helper tool that uses regex to parse gnu help pages. Due to strong inconsistencies between these the results may differ but generally give a good head start.

  • copy a completer for simplicity
cp -r completers/cp_completer completers/ln_completer
  • update the package name in main.go
  • replace root.go
ln --help | caraparse -n ln > completers/ln_completer/cmd/root.go
  • fix issues and add completions as required
	carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
		"backup":           carapace.ActionValues("existing", "nil", "none", "off", "numbered", "t", "simple", "never"),
		"target-directory": carapace.ActionDirectories(),
	})

	carapace.Gen(rootCmd).PositionalAnyCompletion(
		carapace.ActionFiles(""),
	)
  • run the generator
cd carapace/cmd && ./generate.sh > completers.go
  • build & test
docker-compose run --rm build
docker-compose run --rm [bash|elvish|fish|oil|powershell|xonsh|zsh]

asciicast

Description
Languages
Go 99.9%