gcli

command module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2015 License: MIT Imports: 4 Imported by: 0

README

gcli

GitHub release Wercker MIT License Go Documentation

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, run below. It generates new cli skeleton project. At least, you must provide executable name. You can run go build todo application from beginning.

$ gcli new [options] NAME

To see available frameworks,

$ gcli list

See more usage,

$ gcli help

Support frameworks

gcli generates two types of CLI. flag pattern or command pattern.

Flag pattern

Flag pattern is the pattern which executable has only flag options like below (e.g., grep),

$ grep —i -C 4 "some string" /tmp   
    │     │              │           
    │     │               `--------- Arguments 
    │     │                          
    │      `------------------------ Option flags   
    │                                
     `------------------------------ Executable  

To generate above CLI app by gcli with flag fraemwork,

$ cd $GOPATH/src/github.com/YOUR_NAME
$ gcli new -F flag -flag=i:Bool -flag=C:Int grep
  Created grep/main.go
  Created grep/CHANGELOG.md
  Created grep/cli_test.go
  Created grep/README.md
  Created grep/version.go
  Created grep/cli.go
====> Successfully generated grep

For this flag pattern, gcli supports below packages,

Command pattern

Command pattern is the pattern which executable has command for change its behavior. For example, todo CLI application which has add (Add new task), list (List all tasks) and delete(Delete a task) command.

$ todo add 'Buy a milk' 
   │    │      │           
   │    │       `---------- Arguments 
   │    │ 
   │     `----------------- Command 
   │                                  
    `---------------------- Executable

To generate above CLI app by gcli withcommand with mitchellh/cli framework,

$ cd $GOPATH/src/github.com/YOUR_NAME
$ gcli new -F mitchellh_cli -c add -c list -c delete todo
  Created todo/main.go
  Created todo/command/meta.go
  Created todo/cli.go
  Created todo/CHANGELOG.md
  Created todo/version.go
  Created todo/commands.go
  Created todo/command/add.go
  Created todo/command/list.go
  Created todo/command/delete.go
  Created todo/README.md
  Created todo/command/add_test.go
  Created todo/command/list_test.go
  Created todo/command/delete_test.go
====> Successfully generated todo

For this flag pattern, gcli supports below packages,

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

  1. Fork (https://github.com/tcnksm/gcli/fork)
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the make test command and confirm that it passes
  6. Run gofmt -s
  7. Create a new Pull Request

Author

Taichi Nakashima

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL