Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andimiller/decline-completion
A module for the decline command line parser to enable bash and zsh autocomplete
https://github.com/andimiller/decline-completion
cli completion decline scala
Last synced: about 5 hours ago
JSON representation
A module for the decline command line parser to enable bash and zsh autocomplete
- Host: GitHub
- URL: https://github.com/andimiller/decline-completion
- Owner: andimiller
- License: apache-2.0
- Created: 2023-07-29T11:26:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-07T12:50:18.000Z (over 1 year ago)
- Last Synced: 2023-08-13T19:19:23.634Z (over 1 year ago)
- Topics: cli, completion, decline, scala
- Language: Scala
- Homepage:
- Size: 14.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# decline-completion
A module for the decline command line parser to enable bash and zsh autocomplete## Caveats
This is currently oriented around supporting command line interfaces with a lot of subcommands, and will traverse the tree and expose options available on each subcommand for autocomplete.
If you heavily use shared configuration options which are not attached to subcommands, be aware these are currently not supported, but may be in a future release.
## Usage
Add the dependency, currently available for JVM, JS and Native:
```scala
libraryDependencies ++= List(
"net.andimiller" %%% "decline-completion" % "0.0.2"
)
```Add a new subcommand that can expose the output from this library:
```scala
lazy val othercommand = Opts.subcommand("???", "???").as(???)lazy val completion = Opts.subcommand("completion", "output autocompletion scripts for common shells") {
val bash = Opts.subcommand("bash", "output autocompletion script for bash").as(
IO.println(
Completion.bashCompletion(cli)
)
)
val bash = Opts.subcommand("bash", "output autocompletion script for bash").as(
IO.println(
Completion.zshBashcompatCompletion(cli)
)
)}
lazy val cli = Command("myprogram", "my program does things") {
othercommand orElse completion
}
```Then call it on the command line to use it:
### bash
```sh
myprogram completion bash > myprogram-completion.bash
source myprogram-completion.bash
```### zsh
```sh
myprogram completion zsh > myprogram-completion.zsh
source myprogram-completion.zsh
```