gcli
gcli
(formerly cli-init
) generates the codes and its directory structure you need to start building CLI tool by Golang right out of the box. All you need is to provide name, command names and framework you want to use.
Usage
To start new command line tool,
$ gcli new [options] NAME
It generates new cli skeleton project. At least, you must provide executable name.
See more usage,
$ gcli help
Example
If you want to create todo
CLI application which has add
, list
and delete
command with
mitchellh/cli framework,
$ cd $GOPATH/src/github.com/YOUR_NAME
$ gcli new -F mitchellh_cli -c add -c list -c delete todo
You can run go build
todo application from beginning.
Support frameworks
gcli
generates two types of CLI (you can choose). Flag pattern & Command pattern.
Flag pattern
Flag pattern is the pattern which executable has only flag options (e.g., grep)
$ grep —i -C 4 "some string" /tmp
<executable> <options> <arguments>
To generate this pattern, gcli
supports,
Command pattern
Command pattern is the pattern which executable has command for change its behavior (e.g., git
)
$ git --no-pager push -v origin master
<executable> <global options> <command> <command option> <arguments>
To generate this pattern, gcli
supports,
Installation
To install, use go get
and make install
. We tag versions so feel free to checkout that tag and compile.
$ go get -d github.com/tcnksm/gcli
$ cd $GOPATH/src/github.com/tcnksm/gcli
$ make install
gcli
was re-written from scratch. If you prefer old version of gcli
, checkout,
$ git checkout v0.1.0
Contribution
- Fork (https://github.com/tcnksm/gcli/fork)
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the
make test
command and confirm that it passes
- Run
gofmt -s
- Create a new Pull Request
Author
Taichi Nakashima