Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More godoc documentation #24

Merged
merged 6 commits into from
Oct 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ test-docker:
test-functional: build devdeps
@echo "====> Run functional test"
cd tests; go test -v ./...

godoc: build
@echo "====> Generate doc.go"
@rm doc.go
@./bin/gcli -godoc
9 changes: 9 additions & 0 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,22 @@ func Run(args []string) int {
func RunCustom(args []string, commands map[string]cli.CommandFactory) int {

for _, arg := range args {

// If the following options are provided,
// then execute glic version command
if arg == "-v" || arg == "-version" || arg == "--version" {
newArgs := make([]string, len(args)+1)
newArgs[0] = "version"
copy(newArgs[1:], args)
args = newArgs
break
}

// Generating godoc (doc.go). This is only for gcli developper.
if arg == "-godoc" {
return runGodoc(commands)

}
}

cli := &cli.CLI{
Expand Down
13 changes: 8 additions & 5 deletions command/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,15 @@ func (c *ApplyCommand) Synopsis() string {
// and the complete list of flags the command accepts.
func (c *ApplyCommand) Help() string {
helpText := `
Usage: gcli apply [option] FILE
Apply design template file for generating cli project. You can generate
design template file via 'gcli design' command. If framework name is not
specified gcli use codegangsta/cli. You can set framework name via '-F'
option. To check cli framework you can use, run 'gcli list'.

Usage:

gcli apply [option] FILE

Apply design template file for generating cli project. You can generate
design template file via 'gcli design' command. If framework name is not
specified gcli use codegangsta/cli. You can set framework name via '-F'
option. To check cli framework you can use, run 'gcli list'.

Options:

Expand Down
11 changes: 7 additions & 4 deletions command/design.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,14 @@ func (c *DesignCommand) Synopsis() string {
// and the complete list of flags the command accepts.
func (c *DesignCommand) Help() string {
helpText := `
Usage: gcli design [option] NAME
Generate project design template (as toml file). You can pass that file to 'gcli apply'
command and generate CLI tool based on template file. You can define what command
and what flag you need on that file.

Usage:

gcli design [option] NAME

Generate project design template (as toml file). You can pass that file to 'gcli apply'
command and generate CLI tool based on template file. You can define what command
and what flag you need on that file.

Options:

Expand Down
6 changes: 4 additions & 2 deletions command/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ func (c *ListCommand) Synopsis() string {
// and the complete list of flags the command accepts.
func (c *ListCommand) Help() string {
helpText := `
Usage: gcli list
Show all avairable cli frameworks.

Show all avairable cli frameworks.
Usage:

gcli list
`
return strings.TrimSpace(helpText)
}
15 changes: 8 additions & 7 deletions command/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@ func (c *NewCommand) Synopsis() string {
// and the complete list of flags the command accepts.
func (c *NewCommand) Help() string {
helpText := `
Usage: gcli new [option] NAME
Generate new cli skeleton project. At least, you must provide executable
name. You can select cli package and set commands via command line option.
See more about that on Options section. By default, gcli use codegangsta/cli.
To check cli framework you can use, run 'gcli list'.

Generate new cli skeleton project. At least, you must provide executable
name. You can select cli package and set commands via command line option.
See more about that on Options section. By default, gcli use codegangsta/cli.
To check cli framework you can use, run 'gcli list'.
Usage:

gcli new [option] NAME

Options:

Expand Down Expand Up @@ -190,8 +192,7 @@ Options:

Examples:

This example shows creating todo command application skeleton
which has 'add' and 'delete' command by using mitchellh/cli package.
To create todo command application skeleton which has 'add' and 'delete' command,

$ gcli new -command=add:"Add new task" -commnad=delete:"delete task" todo
`
Expand Down
9 changes: 6 additions & 3 deletions command/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@ func (c *ValidateCommand) Synopsis() string {
// and the complete list of flags the command accepts.
func (c *ValidateCommand) Help() string {
helpText := `
Usage: gcli validate FILE
Validate design template file which has required filed. If not it returns
error and non zero value.

Usage:

gcli validate FILE

Validate design template file which has required filed. If not it returns
error and non zero value.
`
return strings.TrimSpace(helpText)
}
163 changes: 163 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
// DO NOT EDIT THIS FILE.
// THIS FILE IS GENERATED BY GO GENERATE.

/*
Command gcli generates a skeleon (codes and its directory structure) you need to start building CLI tool by Golang.
https://github.com/tcnksm/gcli

Usage:

gcli [-version] [-help] <command> [<options>]

Available commands:

apply Apply design template file for generating cli project
design Generate project design template
list List available cli frameworks
new Generate new cli project
validate Validate design template file

Use "gcli <command> -help" for more information about command.



Apply design template file for generating cli project

Apply design template file for generating cli project. You can generate
design template file via 'gcli design' command. If framework name is not
specified gcli use codegangsta/cli. You can set framework name via '-F'
option. To check cli framework you can use, run 'gcli list'.

Usage:

gcli apply [option] FILE


Options:

-framework=name, -F Cli framework name. By default, gcli use "codegangsta/cli"
To check cli framework you can use, run 'gcli list'.
If you set invalid framework, it will be failed.

-skip-test, -T Skip generating *_test.go file. By default, gcli generates
test file If you specify this flag, gcli will not generate
test files.



Generate project design template

Generate project design template (as toml file). You can pass that file to 'gcli apply'
command and generate CLI tool based on template file. You can define what command
and what flag you need on that file.

Usage:

gcli design [option] NAME


Options:

-command=name, -c Command name which you want to add.
This is valid only when cli pacakge support commands.
This can be specified multiple times. Synopsis can be
set after ":". Namely, you can specify command by
-command=NAME:SYNOPSYS. Only NAME is required.
You can set multiple variables at same time with ","
separator.

-flag=name, -f Global flag option name which you want to add.
This can be specified multiple times. By default, flag type
is string and its description is empty. You can set them,
with ":" separator. Namaly, you can specify flag by
-flag=NAME:TYPE:DESCIRPTION. Order must be flow this and
TYPE must be string, bool or int. Only NAME is required.
You can set multiple variables at same time with ","
separator.

-framework=name, -F Cli framework name. By default, gcli use "codegangsta/cli"
To check cli framework you can use, run 'gcli list'.
If you set invalid framework, it will be failed.

-owner=name, -o Command owner (author) name. This value is also used for
import path name. By default, owner name is extracted from
~/.gitconfig variable.


-output, -O Change output file name. By default, gcli use "NAME-design.toml"



List available cli frameworks

Show all avairable cli frameworks.

Usage:

gcli list



Generate new cli project

Generate new cli skeleton project. At least, you must provide executable
name. You can select cli package and set commands via command line option.
See more about that on Options section. By default, gcli use codegangsta/cli.
To check cli framework you can use, run 'gcli list'.

Usage:

gcli new [option] NAME

Options:

-command=name, -c Command name which you want to add.
This is valid only when cli pacakge support commands.
This can be specified multiple times. Synopsis can be
set after ":". Namely, you can specify command by
-command=NAME:SYNOPSYS. Only NAME is required.
You can set multiple variables at same time with ","
separator.

-flag=name, -f Global flag option name which you want to add.
This can be specified multiple times. By default, flag type
is string and its description is empty. You can set them,
with ":" separator. Namaly, you can specify flag by
-flag=NAME:TYPE:DESCIRPTION. Order must be flow this and
TYPE must be string, bool or int. Only NAME is required.
You can set multiple variables at same time with ","
separator.

-framework=name, -F Cli framework name. By default, gcli use "codegangsta/cli"
To check cli framework you can use, run 'gcli list'.
If you set invalid framework, it will be failed.

-owner=name, -o Command owner (author) name. This value is also used for
import path name. By default, owner name is extracted from
~/.gitconfig variable.

-skip-test, -T Skip generating *_test.go file. By default, gcli generates
test file If you specify this flag, gcli will not generate
test files.

Examples:

To create todo command application skeleton which has 'add' and 'delete' command,

$ gcli new -command=add:"Add new task" -commnad=delete:"delete task" todo



Validate design template file

Validate design template file which has required filed. If not it returns
error and non zero value.

Usage:

gcli validate FILE



*/
package main
Loading