Documentation
¶
Index ¶
- Variables
- func CreateAlias(cmd *cobra.Command, invocation string) *cobra.Command
- func CreateAliases(cmd *cobra.Command, invocation string, synonyms ...string) *cobra.Command
- func CreateDocsAlias(command *cobra.Command, invocation string, pattern string) *cobra.Command
- func CreateDocsAliases(command *cobra.Command, invocation string, pattern string, synonyms ...string) *cobra.Command
- func Encoder(format string, w io.Writer) serde.Encoder
- func ErrorAndExitf(format string, args ...interface{})
- func FileMustExist(i int) cobra.PositionalArgs
- func InteractiveConfirm() (bool, error)
- func Main[T pachconfig.AnyConfig](ctx context.Context, do func(context.Context, T) error, appEnv T, ...)
- func MergeCommands(root *cobra.Command, children []*cobra.Command)
- func OutputFlags(raw *bool, output *string) *pflag.FlagSet
- func PagerFlags(noPager *bool) *pflag.FlagSet
- func ParseBranch(project, arg string) (*pfs.Branch, error)
- func ParseBranches(project string, args []string) ([]*pfs.Branch, error)
- func ParseCommit(project, arg string) (*pfs.Commit, error)
- func ParseCommits(project string, args []string) ([]*pfs.Commit, error)
- func ParseFile(project, arg string) (*pfs.File, error)
- func ParseHistory(history string) (int64, error)
- func ParseJob(project, arg string) (*pps.Job, error)
- func ParsePartialFile(project, arg string) *pfs.File
- func ParseRepo(project, name string) *pfs.Repo
- func Populate(object interface{}, decoders ...Decoder) error
- func PopulateDefaults(object interface{}) error
- func PrintStdinReminder()
- func ReadPassword(prompt string) (string, error)
- func Run(run func(cmd *cobra.Command, args []string) error) func(*cobra.Command, []string)
- func RunBoundedArgs(min int, max int, run func(*cobra.Command, []string) error) func(*cobra.Command, []string)
- func RunFixedArgs(numArgs int, run func(*cobra.Command, []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(*cobra.Command, []string) error) func(*cobra.Command, []string)
- func TimestampFlags(fullTimestamps *bool) *pflag.FlagSet
- type Decoder
- type IO
- type RepeatedStringArg
- type TimeFlag
Constants ¶
This section is empty.
Variables ¶
var PrintErrorStacks bool
PrintErrorStacks should be set to true if you want to print out a stack for errors that are returned by the run commands.
Functions ¶
func CreateAlias ¶
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 CreateAliases ¶
CreateAliases is like CreateAlias, except it allows us to specify one or more synonyms for the last argument in the command with the assumption that the last argument in the command is a resource such as 'repo' or 'pipeline'.
func CreateDocsAlias ¶
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 CreateDocsAliases ¶
func CreateDocsAliases(command *cobra.Command, invocation string, pattern string, synonyms ...string) *cobra.Command
CreateDocsAliases is like CreateDocsAlias, except it allows us to specify one or more synonyms for the last argument in the command with the assumption that the last argument in the command is a resource such as 'repo' or 'pipeline'.
func Encoder ¶
Encoder creates an encoder that writes data structures to os.Stdout in the serialization format 'format'. If the 'format' passed is unrecognized (currently, 'format' must be 'json' or 'yaml') then pachctl exits immediately.
func ErrorAndExitf ¶
func ErrorAndExitf(format string, args ...interface{})
ErrorAndExitf errors with the given format and args, and then exits.
func FileMustExist ¶ added in v2.8.0
func FileMustExist(i int) cobra.PositionalArgs
FileMustExist is an argument that can be passed to cobra.Command.Args to ensure that the argument at index i is a file that exists.
func InteractiveConfirm ¶
InteractiveConfirm will ask the user to confirm an action on the command-line with a y/n response.
func Main ¶
func Main[T pachconfig.AnyConfig](ctx context.Context, do func(context.Context, T) error, appEnv T, decoders ...Decoder)
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 ¶
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 PagerFlags ¶
func ParseBranch ¶
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 semantically interchangeable with a commit-id on the command-line.
func ParseBranches ¶
ParseBranches converts all arguments to *pfs.Commit structs using the semantics of ParseBranch.
func ParseCommit ¶
ParseCommit takes an argument of the form "repo[@branch-or-commit]" and returns the corresponding *pfs.Commit.
func ParseCommits ¶
ParseCommits converts all arguments to *pfs.Commit structs using the semantics of ParseCommit
func ParseFile ¶
ParseFile takes an argument of the form "repo[@branch-or-commit[:path]]", and returns the corresponding *pfs.File.
func ParseHistory ¶
ParseHistory parses a --history flag argument. Permissable values are "all" "none", and integers greater than or equal to -1 (as strings).
func ParseJob ¶
ParseJob takes an argument of the form "pipeline@job-id" and returns the corresponding *pps.Job.
func ParsePartialFile ¶
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 PopulateDefaults ¶
func PopulateDefaults(object interface{}) error
PopulateDefaults will parse the tags of the given structure and populate each field with a default value (if specified in the tags). This is meant for use by tests, which do not want to read from env vars.
func PrintStdinReminder ¶
func PrintStdinReminder()
PrintStdinReminder will print a reminder if pachctl expects input on stdin, and stdin is a terminal (and not a pipe from another command or file).
func ReadPassword ¶
ReadPassword reads a password from stdin. If stdin is a TTY, a password prompt will be displayed and the input will be obscured.
func RunBoundedArgs ¶
func RunBoundedArgs(min int, max int, run func(*cobra.Command, []string) error) func(*cobra.Command, []string)
RunBoundedArgs wraps a function in a function that checks its argument count is within a range.
func RunFixedArgs ¶
func RunFixedArgs(numArgs int, run func(*cobra.Command, []string) error) func(*cobra.Command, []string)
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 ¶
func RunMinimumArgs(min int, run func(*cobra.Command, []string) error) func(*cobra.Command, []string)
RunMinimumArgs wraps a function in a function that checks its argument count is above a minimum amount
func TimestampFlags ¶
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
type TimeFlag ¶ added in v2.10.0
TimeFlag implements the pflag.Value interface, enabling RFC3339 (with optional nanoseconds) flag arguments.
func (*TimeFlag) Set ¶ added in v2.10.0
Set implements the pflag.Value interface. It sets the value of the flag to its parsed argument, if it is acceptable RFC 3339 (with optional nanoseconds) format.