added program name and description to the help output
This commit is contained in:
@@ -2,6 +2,7 @@ package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type CliOptionTracer interface {
|
||||
@@ -38,17 +39,33 @@ type OptReference interface {
|
||||
}
|
||||
|
||||
type CliParser struct {
|
||||
version string
|
||||
options []cliOptionParser
|
||||
argSpecs []argSpec
|
||||
cliArgs []string
|
||||
description string
|
||||
version string
|
||||
options []cliOptionParser
|
||||
argSpecs []argSpec
|
||||
cliArgs []string
|
||||
}
|
||||
|
||||
func (cli *CliParser) Init(argv []string, version string) {
|
||||
func (cli *CliParser) Init(argv []string, version string, description string) {
|
||||
cli.version = version
|
||||
cli.description = description
|
||||
cli.cliArgs = argv
|
||||
}
|
||||
|
||||
func (cli *CliParser) GetOption(name string) (ref OptReference) {
|
||||
var opt cliOptionParser
|
||||
if strings.HasPrefix(name, "-") {
|
||||
opt = cli.findOptionByArg(name)
|
||||
} else {
|
||||
opt = cli.findOptionByName(name)
|
||||
}
|
||||
if opt != nil {
|
||||
ref = opt.(OptReference)
|
||||
}
|
||||
return ref
|
||||
|
||||
}
|
||||
|
||||
func (cli *CliParser) SetIncompatibleOption(optName string, incompatibleOptNames ...string) error {
|
||||
var opti cliOptionParser
|
||||
if opti = cli.findOptionByName(optName); opti == nil {
|
||||
|
||||
Reference in New Issue
Block a user