Documentation
¶
Overview ¶
Package cli holds what the command-line programs (backupd, takeout, decrypt, install-bundle) agree on: how flags are parsed and what the exit status means.
Exit status:
0 success, and asking for help (-h) 1 the program ran and failed (wrong key, unreachable store, bad configuration in the environment) 2 the command line was wrong (unknown flag or command, a missing required flag, a stray argument); nothing was attempted
The package never exits and never writes to the process's own streams; it is handed the writers, so every path is testable.
Index ¶
Constants ¶
const ( ExitOK = 0 ExitFailure = 1 ExitUsage = 2 )
Exit statuses.
Variables ¶
This section is empty.
Functions ¶
func IsUsage ¶
IsUsage reports whether err is a usage error or a request for help, i.e. something that is about the command line rather than the work.
func Parse ¶
Parse parses args into fs. None of these programs takes positional arguments, so one is refused rather than silently ignored.
Asked for help (-h, -help), it writes the usage text to stdout, because that is the output asked for, and returns flag.ErrHelp. A malformed command line has its error and the usage text written to stderr and comes back as a *UsageError.
Types ¶
type UsageError ¶
type UsageError struct {
Err error
// contains filtered or unexported fields
}
UsageError is a command line that cannot be acted on. Nothing was attempted, and running the same thing again will fail the same way.
func (*UsageError) Error ¶
func (e *UsageError) Error() string
func (*UsageError) Unwrap ¶
func (e *UsageError) Unwrap() error