Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Dash = "-"
Dash -
var DashDash = "--"
DashDash --
var LongFlagPrefix = DashDash
LongFlagPrefix is the default prefix appended to multi-character flags in a command.
var ShortFlagPrefix = Dash
ShortFlagPrefix The default prefix applied to single-character flags in a command.
Functions ¶
This section is empty.
Types ¶
type T ¶
type T struct { // The prefix of the command. // gitLog := commands.Cmd{First: []string{"git", "log"}}.Flag("short", true) First []string // Flags handles several different types when it comes to flag values: // - nil: the flag will not be set. // - string: the flag will be set to the string. // - fmt.Stringer: the flag will be set to `value.String()`. // - []string: the flag will be set once for each string in the slice. For // example, {"add: []string{"etc", "usr", "opt"}} will be built into final // arguments "--add", "etc", "--add", "usr", "--add", "opt" // - bool: if the value is true, the flag is added without an argument. // - any: flag will be added with the value printed using // `fmt.Sprintf("%v", value)` Flags map[string]interface{} // Args are joined after all the flag options. Args []string // The prefix attatched to flags if the flags are longer than one character. // A nil pointer uses the default of "--". LongFlagPrefix *string // The prefix attatched to flags if the flags are one character long. // A nil pointer uses the default of "-". ShortFlagPrefix *string // A seperator between the last flag and the first arg. // A nil pointer omits the seperator. FlagsSeperator *string }
command.T is a factory for creating *exec.Cmd structs. Create one manually, or use the builder function `New()`. Consider using the `T.Flag` and `T.Arg` methods to mutate your command, then use `T.Build()` to return an *exec.Cmd that's ready to run.
func (*T) Build ¶
Build an *exec.Cmd from this Cmd. This returns a new *exec.Cmd on each call, allowing you to use a Cmd as a factory.
func (*T) Join ¶
Join prepends this command to another command, mutating and returning the second command. This is useful for building multi-level commands.
TODO: copy instead of mutate?