Documentation
¶
Overview ¶
Package gocmd is a library for building command line applications
Index ¶
- type Cmd
- func (cmd *Cmd) Description() string
- func (cmd *Cmd) FlagErrors() []error
- func (cmd *Cmd) FlagValue(name string) interface{}
- func (cmd *Cmd) LookupFlag(name string) ([]string, bool)
- func (cmd *Cmd) Name() string
- func (cmd *Cmd) PrintUsage()
- func (cmd *Cmd) PrintVersion(extra bool)
- func (cmd *Cmd) Version() string
- type Options
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Cmd represents a command
func (*Cmd) Description ¶
Description returns the description of the command
func (*Cmd) FlagErrors ¶
FlagErrors returns the list of the flag errors
func (*Cmd) LookupFlag ¶
LookupFlag returns the flag arguments by the given flag name
func (*Cmd) PrintUsage ¶
func (cmd *Cmd) PrintUsage()
PrintUsage prints usage
Example ¶
cmd, _ := gocmd.New(gocmd.Options{
Name: "test",
Version: "1.0.0",
Description: "Test",
})
cmd.PrintUsage()
Output: Usage: test Test
func (*Cmd) PrintVersion ¶
PrintVersion prints version information
Example ¶
cmd, _ := gocmd.New(gocmd.Options{
Version: "1.0.0",
})
cmd.PrintVersion(false)
Output: 1.0.0
Example (Extra) ¶
cmd, _ := gocmd.New(gocmd.Options{
Name: "test",
Version: "1.0.0",
})
cmd.PrintVersion(true)
Output: App name : test App version : 1.0.0 Go version : TEST
type Options ¶
type Options struct {
// Name is the command name
Name string
// Version is the command version
Version string
// Description is the command description
Description string
// Flags hold user defined command line arguments and commands
Flags interface{}
// AutoHelp prints the usage content
AutoHelp bool
// AutoVersion prints the version content
AutoVersion bool
}
Options represents the options that can be set when creating a new command
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
A basic app
|
A basic app |
|
Package flagset provides functions for handling command line arguments
|
Package flagset provides functions for handling command line arguments |
|
Package table provides functions for handling tables in terminal
|
Package table provides functions for handling tables in terminal |
|
Package template provides functions for handling templates
|
Package template provides functions for handling templates |
Click to show internal directories.
Click to hide internal directories.