Documentation ¶
Index ¶
- func CreateAlias(cmd *cobra.Command, invocation string) *cobra.Command
- func CreateDocsAlias(command *cobra.Command, invocation string, pattern string) *cobra.Command
- func ErrorAndExit(format string, args ...interface{})
- func Main(do func(interface{}) error, appEnv interface{}, decoders ...Decoder)
- func MergeCommands(root *cobra.Command, children []*cobra.Command)
- func ParseBranch(arg string) (*pfs.Branch, error)
- func ParseBranches(args []string) ([]*pfs.Branch, error)
- func ParseCommit(arg string) (*pfs.Commit, error)
- func ParseCommitProvenance(arg string) (*pfs.CommitProvenance, error)
- func ParseCommitProvenances(args []string) ([]*pfs.CommitProvenance, error)
- func ParseCommits(args []string) ([]*pfs.Commit, error)
- func ParseFile(arg string) (*pfs.File, error)
- func ParseFiles(args []string) ([]*pfs.File, error)
- func ParseHistory(history string) (int64, error)
- func ParsePartialFile(arg string) *pfs.File
- func Populate(object interface{}, decoders ...Decoder) error
- func Run(run func(args []string) error) func(*cobra.Command, []string)
- func RunBoundedArgs(min int, max int, run func([]string) error) func(*cobra.Command, []string)
- func RunCmdFixedArgs(numArgs int, run func(*cobra.Command, []string) error) func(*cobra.Command, []string)
- func RunFixedArgs(numArgs int, run func([]string) error) func(*cobra.Command, []string)
- func RunIO(ioObj IO, args ...string) error
- func RunIODirPath(ioObj IO, dirPath string, args ...string) error
- func RunMinimumArgs(min int, run func([]string) error) func(*cobra.Command, []string)
- func RunStdin(stdin io.Reader, args ...string) error
- type Decoder
- type IO
- type RepeatedStringArg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateAlias ¶ added in v1.8.8
CreateAlias generates a nested command tree for the invocation specified, which should be space-delimited as on the command-line. The 'Use' field of 'cmd' should specify '{{alias}}' instead of the command name as that will be filled in based on each invocation. Similarly, for the 'Example' field, '{{alias}}' will be replaced with the full command path. These commands can later be merged into the final Command tree using 'MergeCommands' below.
func CreateDocsAlias ¶ added in v1.8.8
CreateDocsAlias sets the usage string for a docs-style command. Docs commands have no functionality except to output some docs and related commands, and should not specify a 'Run' attribute.
func ErrorAndExit ¶
func ErrorAndExit(format string, args ...interface{})
ErrorAndExit errors with the given format and args, and then exits.
func Main ¶
Main runs the common functionality needed in a go main function. appEnv will be populated and passed to do, defaultEnv can be nil if there is an error, os.Exit(1) will be called.
func MergeCommands ¶ added in v1.8.8
MergeCommands merges several command aliases (generated by 'CreateAlias' above) into a single coherent cobra command tree (with root command 'root'). Because 'CreateAlias' generates empty commands to preserve the right hierarchy, we go through a little extra effort to allow intermediate 'docs' commands to be preserved in the final command structure.
func ParseBranch ¶ added in v1.8.8
ParseBranch takes an argument of the form "repo[@branch]" and returns the corresponding *pfs.Branch. This uses ParseCommit under the hood because a branch name is usually interchangeable with a commit-id.
func ParseBranches ¶ added in v1.7.0
ParseBranches converts all arguments to *pfs.Commit structs using the semantics of ParseBranch
func ParseCommit ¶ added in v1.8.8
ParseCommit takes an argument of the form "repo[@branch-or-commit]" and returns the corresponding *pfs.Commit.
func ParseCommitProvenance ¶ added in v1.9.8
func ParseCommitProvenance(arg string) (*pfs.CommitProvenance, error)
ParseCommitProvenance takes an argument of the form "repo@branch=commit" and returns the corresponding *pfs.CommitProvenance.
func ParseCommitProvenances ¶ added in v1.9.8
func ParseCommitProvenances(args []string) ([]*pfs.CommitProvenance, error)
ParseCommitProvenances converts all arguments to *pfs.CommitProvenance structs using the semantics of ParseCommitProvenance
func ParseCommits ¶
ParseCommits converts all arguments to *pfs.Commit structs using the semantics of ParseCommit
func ParseFile ¶ added in v1.8.8
ParseFile takes an argument of the form "repo[@branch-or-commit[:path]]", and returns the corresponding *pfs.File.
func ParseFiles ¶ added in v1.8.8
ParseFiles converts all arguments to *pfs.Commit structs using the semantics of ParseFile
func ParseHistory ¶ added in v1.8.8
ParseHistory parses a --history flag argument. Permissable values are "all" "none", and integers greater than or equal to -1 (as strings).
func ParsePartialFile ¶ added in v1.9.12
ParsePartialFile returns the same thing as ParseFile, unless ParseFile would error on this input, in which case it returns as much as it was able to parse.
func Populate ¶
Populate populates an object with environment variables.
The environment has precedence over the decoders, earlier decoders have precedence over later decoders.
func RunBoundedArgs ¶
RunBoundedArgs wraps a function in a function that checks its argument count is within a range.
func RunCmdFixedArgs ¶ added in v1.8.8
func RunCmdFixedArgs(numArgs int, run func(*cobra.Command, []string) error) func(*cobra.Command, []string)
RunCmdFixedArgs wraps a function in a function that checks its exact argument count. The only difference between this and RunFixedArgs is that this passes in the cobra command.
func RunFixedArgs ¶
RunFixedArgs wraps a function in a function that checks its exact argument count.
func RunIODirPath ¶
RunIODirPath runs the command with the given IO and arguments in the given directory specified by dirPath.
func RunMinimumArgs ¶ added in v1.8.8
RunMinimumArgs wraps a function in a function that checks its argument count is above a minimum amount
Types ¶
type RepeatedStringArg ¶
type RepeatedStringArg []string
RepeatedStringArg is an alias for []string
func (*RepeatedStringArg) Set ¶
func (r *RepeatedStringArg) Set(s string) error
Set adds a string to r
func (*RepeatedStringArg) String ¶
func (r *RepeatedStringArg) String() string
func (*RepeatedStringArg) Type ¶
func (r *RepeatedStringArg) Type() string
Type returns the string representation of the type of r