console-autocompletion
v0.0.2
Published
A helper tool to auto complete command
Downloads
3
Maintainers
Readme
Console Autocompletion
This is a sub project for c++ flag parser console. But it can be used for general purpose.
How to use
- Install the package.
npm install -g console-autocompletion
- Prepare json file describing your flgas.
[
{
"shortName": "-n1",
"longName": "--number1",
"needsValue": true
},
{
"shortName": "-n2",
"longName": "--number2",
"needsValue": true
}
]
- Copy to
~/.console-autocompletion/
.
cp /path/to/json ~/.console-autocompletion/
- Generate
bash_completion
and activate it.
console-autocompletion-installer program_name /path/to/bash_completion
source /path/to/bash_completion
Flag
name
: name of the flag, ifname
is set,shortName
orlongName
should not be set. At this locaiton, value should be come. It means it's a positional flag.shortName
: '-' prefixed name, ifshortName
is set,name
should not be set. It means it's an optional flag.longName
: '--' prefixed name, iflongName
is set,name
should not be set. It means it's an optional flag.needsValue
: If it is set to true, this optional flag should be followed by value.isSequential
: If it is set to true, this optional flag can be come multiple times.subFlags
: If it is set, after this positional flag, the subarray will be parsed.