Documentation ¶
Index ¶
- Variables
- type Opts
- func (o *Opts) Author(author string) *Opts
- func (o *Opts) ConfigPath(path string) *Opts
- func (o *Opts) DocAfter(target, newid, template string) *Opts
- func (o *Opts) DocBefore(target, newid, template string) *Opts
- func (o *Opts) DocSet(id, template string) *Opts
- func (o *Opts) Help() string
- func (o *Opts) Name(name string) *Opts
- func (o *Opts) Parse() *Opts
- func (o *Opts) ParseArgs(args []string) *Opts
- func (o *Opts) PkgAuthor() *Opts
- func (o *Opts) PkgRepo() *Opts
- func (o *Opts) Process(args []string) error
- func (o *Opts) Repo(repo string) *Opts
- func (o *Opts) UseEnv() *Opts
- func (o *Opts) Version(version string) *Opts
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultOrder = []string{
"usage",
"args",
"arglist",
"options",
"subcmds",
"author",
"version",
"repo",
"errmsg",
}
View Source
var DefaultTemplates = map[string]string{
"help": `{{ $root := . }}` +
`{{range $t := .Order}}{{ templ $t $root }}{{end}}`,
"usage": `Usage: {{.Name }}` +
`{{template "usageoptions" .}}` +
`{{template "usageargs" .}}` +
`{{template "usagearglist" .}}` +
`{{template "usagesubcmd" .}}` + "\n",
"usageoptions": `{{if .Opts}} [options]{{end}}`,
"usageargs": `{{range .Args}} {{.Name}}{{end}}`,
"usagearglist": `{{if .ArgList}} {{.ArgList.Name}}{{end}}`,
"usagesubcmd": `{{if .Subcmds}} <subcommand>{{end}}`,
"helpextra": `{{if .Def}}default {{.Def}}{{end}}` +
`{{if and .Def .Env}}, {{end}}` +
`{{if .Env}}env {{.Env}}{{end}}`,
"args": `{{range .Args}}{{template "arg" .}}{{end}}`,
"arg": "{{if .Help}}\n{{.Help}}\n{{end}}",
"arglist": "{{if .ArgList}}{{ if .ArgList.Help}}\n{{.ArgList.Help}}\n{{end}}{{end}}",
"options": `{{if .Opts}}` + "\nOptions:\n" +
`{{ range $opt := .Opts}}{{template "option" $opt}}{{end}}{{end}}`,
"option": `{{.Name}}{{if .Help}}{{.Pad}}{{.Help}}{{end}}` + "\n",
"subcmds": "{{if .Subcmds}}\nSubcommands:\n" +
`{{ range $sub := .Subcmds}}{{template "subcmd" $sub}}{{end}}{{end}}`,
"subcmd": "* {{ .Name }}{{if .Help}} - {{ .Help }}{{end}}\n",
"version": "{{if .Version}}\nVersion:\n{{.Pad}}{{.Version}}\n{{end}}",
"repo": "{{if .Repo}}\nRead more:\n{{.Pad}}{{.Repo}}\n{{end}}",
"author": "{{if .Author}}\nAuthor:\n{{.Pad}}{{.Author}}\n{{end}}",
"errmsg": "{{if .ErrMsg}}\nError:\n{{.Pad}}{{.ErrMsg}}\n{{end}}",
}
Functions ¶
This section is empty.
Types ¶
type Opts ¶
type Opts struct { //public format settings LineWidth int //42 PadAll bool //true PadWidth int //2 // contains filtered or unexported fields }
Opts is the main class, it contains all parsing state for a single set of arguments
func (*Opts) ConfigPath ¶
ConfigPath defines a path to a JSON file which matches the structure of the provided config. Environment variables override JSON Config variables.
Click to show internal directories.
Click to hide internal directories.