Documentation
¶
Overview ¶
Package cli is the prodmask command line. The free build's commands live here behind a small registry, so another build can add commands of its own and keep the same flags, output and exit statuses for the free ones.
Index ¶
Constants ¶
const ( ExitOK = 0 ExitError = 1 ExitUsage = 2 ExitFindings = 3 ExitLicence = 4 // a command that needs a prodmask Pro licence found no valid one )
Exit statuses. Every build shares them, so a status means the same thing whichever command returns it.
Variables ¶
This section is empty.
Functions ¶
func BuildVersion ¶
BuildVersion returns the version a build reports: stamped when the build set it with -ldflags "-X main.version=...", otherwise the module version Go recorded for go install or go build, otherwise "dev".
Types ¶
type App ¶
type App struct {
Version string // shown by prodmask version and recorded in reports
Edition string // the build's name after "prodmask", such as "Pro"; empty for the free build
About string // the paragraph above the command list
// contains filtered or unexported fields
}
App is one build of prodmask: its version, the text around its command list, and its commands.
func (*App) Register ¶
Register adds commands. It panics if a command has no name or Run function, or if a name or alias is already taken, as these are mistakes in the program rather than in its input.
func (*App) Usage ¶
Usage returns the help text: the about paragraph, the commands in name order, and the footer.
func (*App) VersionLine ¶
VersionLine is what prodmask version prints, such as "prodmask 0.1.0".
type Command ¶
type Command struct {
Name string // the word that selects it: prodmask <Name>
Aliases []string // other words that select it, such as --version; not listed
Args string // what follows the name in the command list, such as "[flags]"
Summary string // its line in the command list
// Run runs the command with the arguments after its name and returns
// the exit status.
Run func(ctx context.Context, env *Env, args []string) int
}
Command is one prodmask command, such as scan.
func FreeCommands ¶
func FreeCommands() []*Command
FreeCommands returns new copies of the free build's commands, for builds that add their own.