A generator for Zsh completion function
zgencomp
is CLI tool that automatically generates a completion function for Zsh. It generates the function based on the JSON file that you wrote about user interface of your command.
DEMO:
- Easily and instantly generatable
- Just edit JSON file
- Go
-
To generate the sample/template JSON file:
$ zgencomp -g
-
Edit the JSON file
-
To generate the completion function:
$ zgencomp
After that you just placed the generated file to $fpath
.
Note:
-
If
zgencomp -g
is called without arguments, it generatessample.json
. If you desire the name that is not asample.json
, it can be changed:
$ zgencomp --generate=mycmd.json ```
-
Calling
zgencomp
without any arguments readssample.json
in the current directory. To read other json files:
$ zgencomp mycmd.json ```
For more information about zgencomp
, type zgencomp --help
in your Terminal.
Paste the following commands at a Terminal prompt.
$ go get github.com/b4b4r07/zgencomp
$ cd $GOPATH/src/github.com/b4b4r07/zgencomp
$ make install
After installation, you only edit json
file. Put the sample json file here.
Note:
I have extended the json file used by zgencomp
. Thanks to that, you can write a comment of JavaScript style within the json file. Please check here for how to set up the json file.
{
"command" : "mycmd",
"properties" : {
"author" : "John Doe",
"license" : "MIT",
"help" : {
"option" : [
"--help"
],
"description" : "Print a brief help message."
},
"version" : {
"option" : [
"-V",
"--version"
],
"description" : "Display version information and exit."
}
},
"options" : {
"switch" : [
{
"option" : [
"-c",
"--count"
],
"description" : "Only a count of selected lines is written to standard output.",
"exclusion" : [
]
},
{
"option" : [
],
"description" : ""
}
],
"flag" : [
{
"option" : [
"-m",
"--max-count"
],
"description" : "Stop reading the file after num matches.",
"exclusion" : [
"-c",
"--count"
],
"argument" : {
"group" : "",
"type" : "func",
"style" : {
"standard" : ["-m"],
"touch" : [],
"touchable" : [],
"equal" : ["--max--count"],
"equalable" : []
}
}
},
{
"option" : [
],
"description" : "",
"exclusion" : [
],
"argument": {
"group" : "",
"type" : "",
"style" : {
"standard" : [],
"touch" : [],
"touchable" : [],
"equal" : [],
"equalable" : []
}
}
}
]
},
"arguments" : {
"always" : true,
"type" : "func"
}
}