Skip to content

Latest commit

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

completely

Generate shell completion scripts from a JSON description of a command.

Usage

You can use the CLI to generate scripts:

npm i -g @completely/cli
completely --shell bash completion.json > completion.sh

(Only bash and zsh are supported at the moment.)

For example, given this JSON description:

{
"command": "my-command",
"subcommands": [
{
"command": "draw",
"args": [],
"flags": [{
"type": "string",
"name": "color",
"completion": {
"type": "oneOf",
"values": ["red", "green", "blue"]
}
}]
}
]
}

If you generate a completion.sh file and source it, you'll get some completion suggestions:

source completion.sh
my-command # pressing <tab> will complete "draw"
my-command draw --color # pressing <tab><tab> will suggest "red", "green" and "blue"

You can also use the library directly:

npm i @completely/bash-generator
import{generate}from'@completely/bash-generator'importcompletionSpecfrom'./completion.json'constscript=generate(completionSpec)console.log(script)

JSON description

You can check the spec package to learn more about how to describe a command with a JSON file. Ideally you wouldn't need to do this manually, since this JSON is meant to be an internal representation generated by other means.

About

Generate shell completion scripts from a JSON description of a command.

Topics

Resources

Stars

27 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages