Documentation ¶
Overview ¶
Package cmdutil provides utility routines for implementing command line tools.
Index ¶
- func CheckAccess(ctx *context.T) (time.Duration, error)
- func CreateInfoCommand(name, prefix string, info ...func(*context.T, *cmdline.Env, []string) error) *cmdline.Command
- func CreateVersionCommand(name, prefix string) *cmdline.Command
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func RegisterTicketFlags(fs *flag.FlagSet, prefix string, defaultTickets []string, flags *TicketFlags)
- func RunnerFuncWithAccessCheck(ctxfn func() *context.T, run func(*context.T, *cmdline.Env, []string) error) cmdline.Runner
- func V23RunnerFunc(ctxfn func() *context.T, run func(*context.T, *cmdline.Env, []string) error) cmdline.Runner
- func WriteBlessings(ctx *context.T, out io.Writer)
- func WriteWrappedMessage(w io.Writer, m string)
- type NetworkAddressFlag
- type RunnerFunc
- type TicketFlags
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAccess ¶
CheckAccess checkes that the current process has credentials that will be valid for at least another 30 minutes. It is intended to allow for more useful and obvious error reporting.
func CreateInfoCommand ¶
func CreateInfoCommand(name, prefix string, info ...func(*context.T, *cmdline.Env, []string) error) *cmdline.Command
CreateInfoCommand creates a command akin to that created by CreatedVersionCommand but also includes the output of running each of the supplied info closures.
func CreateVersionCommand ¶
CreateVersionCommand creates a cmdline 'subcommand' to display version information.
The format of the information printed is:
<prefix>/<version> (<tag1>; <tag2>; ...)
The version and tags are set at build time using something like:
go build -ldflags \ "-X github.com/grailbio/base/cmdutil.version=$version \ -X github.com/grailbio/base/cmdutil.tags=$tags"
func Fatal ¶
func Fatal(args ...interface{})
Fatal mirrors log.Fatal with no prefix and no timestamp.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf mirrors log.Fatalf with no prefix and no timestamp.
func RegisterTicketFlags ¶
func RegisterTicketFlags(fs *flag.FlagSet, prefix string, defaultTickets []string, flags *TicketFlags)
RegisterTicketFlags registers the ticket related flags with the supplied FlagSet. The flags are: --<prefix>ticket --<prefix>ticket-timeout --<prefix>ticketrc
func RunnerFuncWithAccessCheck ¶
func RunnerFuncWithAccessCheck(ctxfn func() *context.T, run func(*context.T, *cmdline.Env, []string) error) cmdline.Runner
RunnerFuncWithAccessCheck is like V23RunnerFunc, but also calls CheckAccess to test for credential existence/expiry.
func V23RunnerFunc ¶
func V23RunnerFunc(ctxfn func() *context.T, run func(*context.T, *cmdline.Env, []string) error) cmdline.Runner
V23RunnerFunc is like cmdutil.RunnerFunc, but allows for a context.T parameter that is given the context as obtained from ctxfn.
func WriteBlessings ¶
WriteBlessings will write the current principal and blessings to the supplied io.Writer.
func WriteWrappedMessage ¶
WriteWrappedMessage writes the message to the specified io.Writer taking care to line wrap it appropriately for the terminal width.
Types ¶
type NetworkAddressFlag ¶
NetworkAddressFlag represents a network address in host:port format.
func (*NetworkAddressFlag) Get ¶
func (na *NetworkAddressFlag) Get() interface{}
Get implements flag.Value.Get
func (*NetworkAddressFlag) Set ¶
func (na *NetworkAddressFlag) Set(v string) error
Set implements flag.Value.Set
func (*NetworkAddressFlag) String ¶
func (na *NetworkAddressFlag) String() string
String implements flag.Value.String
type RunnerFunc ¶
RunnerFunc is an adapter that turns regular functions into cmdline.Runners.
type TicketFlags ¶
type TicketFlags struct { Tickets []string TicketRCFile string Timeout time.Duration // contains filtered or unexported fields }
TicketFlags represents an implementation of flag.Value that can be used to specify tickets either in comma separated form or by repeating the same flag. That is, either:
--flag=t1,t2,t3
and/or
--flag=t1 --flag=t2 --flag=t3
and/or
--flag=t1,t2 --flag=t3
func (*TicketFlags) ReadEnvOrFile ¶
func (tf *TicketFlags) ReadEnvOrFile() error
ReadEnvOrFile will attempt to obtain values for the tickets to use from the environment or from a file if none have been explicitly set on the command line. If no flags were specified it will read the environment variable GRAIL_TICKETS and if that's empty it will attempt to read the file specified by the ticketrc flag (or it's default value).
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package interactive is switching defaults for logging to not output anything to stderr.
|
Package interactive is switching defaults for logging to not output anything to stderr. |