https://github.com/zypeh/docflag
Make your help/usage page looks cleaner!
https://github.com/zypeh/docflag
Last synced: 12 months ago
JSON representation
Make your help/usage page looks cleaner!
- Host: GitHub
- URL: https://github.com/zypeh/docflag
- Owner: zypeh
- License: mit
- Created: 2015-08-03T16:24:46.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-08-19T12:52:53.000Z (almost 11 years ago)
- Last Synced: 2024-04-18T21:02:56.191Z (about 2 years ago)
- Language: Go
- Homepage:
- Size: 973 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Docflag
Docflag implements command-line flag parsing with simple and intuitive style.
The code is inspired by the revel/cmd package.
```
import "github.com/Zypeh/docflag"
func main() {
docflag.Parse()
}
```
It offers:
* both short and long description
use "help [command]" for more information
here is how we include our command's description
```
var cmdTest = &Command{
UsageLine: "test [time of repeats] [string]",
Short "Simple Example - Echo function",
Long: `
This is the long description to be shown when you help [command].
`
}
```
* Simple adding commands
adding your command in main.go, for example, cmdBuild.
```
// Add your command here
var commands = []*Command {
cmdTest,
// .... Add your command here ...
cmdBuild,
}
```
and start writing your function under the command.
```
package docflag
func init () {
cmdBuild.Run = build
}
func Build (args []string) { ... }
```
* Usage template file.
simply edit the template file in the App.cfg
```
[App]
AppName = "Echo-go"
Header = "-----[[ Simple Echo ]]-----"
[Template]
usageTemplate = "Usage: echo-go command [arguments]"
// SNIP...
```