Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fvictorio/completely
Generate shell completion scripts from a JSON description of a command.
https://github.com/fvictorio/completely
autocomplete cli completion shell typescript
Last synced: 3 months ago
JSON representation
Generate shell completion scripts from a JSON description of a command.
- Host: GitHub
- URL: https://github.com/fvictorio/completely
- Owner: fvictorio
- Created: 2019-11-14T19:50:40.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-11T11:12:29.000Z (over 3 years ago)
- Last Synced: 2024-10-18T18:54:15.326Z (3 months ago)
- Topics: autocomplete, cli, completion, shell, typescript
- Language: Shell
- Homepage:
- Size: 148 KB
- Stars: 28
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```json
{
"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:
```bash
source completion.sh
my-command # pressing will complete "draw"
my-command draw --color # pressing will suggest "red", "green" and "blue"
```You can also use the library directly:
```
npm i @completely/bash-generator
``````typescript
import { generate } from '@completely/bash-generator'
import completionSpec from './completion.json'const script = generate(completionSpec)
console.log(script)
```## JSON description
You can check the [spec package](packages/spec) 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.