Skip to content

Commit

Permalink
Merge pull request #9 from tcnksm/rewrite-cli-init
Browse files Browse the repository at this point in the history
Rewrite cli-init from scratch
  • Loading branch information
tcnksm committed Jun 14, 2015
2 parents 55206a5 + 0bc114d commit eafe9c2
Show file tree
Hide file tree
Showing 66 changed files with 3,024 additions and 434 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
templates.go
*.test
bin/
2 changes: 1 addition & 1 deletion LICENCE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014 tcnksm
Copyright (c) 2015 Taichi Nakashima

MIT License

Expand Down
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
DEBUG_FLAG = $(if $(DEBUG),-debug)

deps:
go get github.com/jteeuwen/go-bindata/...
go get -d -t ./...
go get -v github.com/jteeuwen/go-bindata/...
go get -v -d -t ./...

test: deps
go test -v ./...
build: deps
cd skeleton; go-bindata -pkg="skeleton" resource/...
go build -o bin/gcli

install: deps
go-bindata $(DEBUG_FLAG) -o templates.go templates
cd skeleton; go-bindata -pkg="skeleton" resource/...
go install

test: build
go test ./...

tests: build
cd tests; go test -v ./...

63 changes: 35 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cli-init
cli-init
====

[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)][license]
Expand All @@ -7,51 +7,52 @@ cli-init
[license]: https://github.com/tcnksm/cli-init/blob/master/LICENSE
[godocs]: http://godoc.org/github.com/tcnksm/cli-init

The easy way to start building Golang command-line application.
The easy way to start building Command-line application by Golang.

## Description

`cli-init` is the easy way to start building Golang command-line application with [codegangsta/cli](https://github.com/codegangsta/cli). All you need to do is to set application name and its subcommand. `cli-init` generates its templates (scaffold) which you need to write when using codegangsta/cli. You can focus on core functionality of application.

## Demo

![](http://deeeet.com/images/cli-init.gif)
`cli-init` generates the codes and its directory structure you need to start building CLI tool right out of the box.
All you need is to provide name, commands and [framework]() you want to use.

## Usage

You just need to set its application name:
To start new command line tool,

```bash
$ cli-init [options] [application]
$ cli-init new [options] NAME
```
It generates new cli skeleton project. At least, you must provide executable name.

You can set subcommands with `-s` option:
## Example

If you want to create `todo` CLI application which has `add`, `list` and `delete` command with
[mitchellh/cli](https://github.com/mitchellh/cli) framework,

```bash
$ cli-init -s subcommand1,subcommand2,subcommand3 [application]
$ cd $GOPATH/src/github.com/YOUR_NAME
$ cli-init new -F mitchellh_cli -c add -c list -c delete todo
```

## Artifacts
You can run `go build` todo application from beginning.

`cli-init` generates templates (scaffold) which you need to write when using [codegangsta/cli](https://github.com/codegangsta/cli):
## Support frameworks

- **main.go** - defines main function. It includes application name, version, usage, author name and so on.
- **commands.go** - defines sub-commands. It includes subcommand name, usage, function and so on.
- **version.go** - defines application version. default value is `0.1.0`
- **README.md** - insctructs application name, synopsis, usage and installation and so on.
- **CHANGELOG.md** - shows version release date and its updates.
`cli-init` supports bellow cli frameworks,

See more details [codegangsta/cli](https://github.com/codegangsta/cli).
- [codegangsta_cli](https://github.com/codegangsta/cli)
- [mitchellh_cli](https://github.com/mitchellh/cli)
- [go_cmd]() (Standard `go` command style)
- [flag](https://golang.org/pkg/flag/)

## Example
`cli-init` has tempaltes of these frameworks. Template file includes best practices of each frameworks like
how to separate file or how to set directory structure and so on.

If you want to start to building `todo` application which has subcommands `add`, `list`, `delete`:
In future, we will also suppport other CLI frameworks like below (Need help),

```bash
$ cli-init -s add,list,delete todo
```

You can see sample of artifacts in [tcnksm-sample/cli-init](https://github.com/tcnksm-sample/cli-init).
- [spf13/cobra](https://github.com/spf13/cobra)
- [docopt.go](https://github.com/docopt/docopt.go)
- [motemen/cli](https://github.com/motemen/cli)
- [mow.cli](https://github.com/jawher/mow.cli)
- [ogier/pflag](https://github.com/ogier/pflag)
- [go-flags](https://github.com/jessevdk/go-flags)

## Installation

Expand All @@ -63,6 +64,12 @@ $ cd $GOPATH/src/github.com/tcnksm/cli-init
$ make install
```

`cli-init` was re-written from scratch. If you prefer old version of `cli-init`, checkout,

```bash
$ git checkout v0.1.0
```

## Contribution

1. Fork ([https://github.com/tcnksm/cli-init/fork](https://github.com/tcnksm/cli-init/fork))
Expand Down
227 changes: 0 additions & 227 deletions cli-init.go

This file was deleted.

Loading

0 comments on commit eafe9c2

Please sign in to comment.