Skip to content

kettsun0123/zgencomp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zgencomp

Build Status

A generator for Zsh completion function

Description

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:

zgencomp.gif

Features

  • Easily and instantly generatable
  • Just edit JSON file

Requirement

  • Go

Usage

  1. To generate the sample/template JSON file:

    $ zgencomp -g
  2. Edit the JSON file

  3. 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 generates sample.json. If you desire the name that is not a sample.json, it can be changed:

$ zgencomp --generate=mycmd.json ```

  • Calling zgencomp without any arguments reads sample.json in the current directory. To read other json files:

$ zgencomp mycmd.json ```

For more information about zgencomp, type zgencomp --help in your Terminal.

Installation

Paste the following commands at a Terminal prompt.

$ go get github.com/b4b4r07/zgencomp
$ cd $GOPATH/src/github.com/b4b4r07/zgencomp
$ make install

Just edit json

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"
    }
}

Author

@b4b4r07

Licence

MIT

About

A generator for Zsh completion function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 94.1%
  • Smarty 5.5%
  • Makefile 0.4%