Documentation
¶
Overview ¶
The app package provides a simple App struct to describe a command-line application, and a Usage interface, which describers the global and command-specific usage of the App.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetVersionMetadata ¶
func SetVersionMetadata(metadata VersionMetadata)
Sets the version metadata for the build. One pattern for setting version metadata is to provide a generated file in the project's main package that constructs a VersionMetadata object and invokes this method.
Note that go build tags (see https://golang.org/pkg/go/build/) may be used to provide compile-time alternates for release builds.
Types ¶
type App ¶
type App struct { Name string // the binary name of the application Description string // a short description of what the application does VersionString string // the current version of the application HasSubCmds bool // whether or not the app has sub commands }
A simple representation of a command-line application
func (App) RedirectedUsage ¶
RedirectedUsage produces a Usage for this App, which prints tab-formatted output to the given Writer at a width of 80 columns.
type MockUsage ¶
type MockUsage struct {
// contains filtered or unexported fields
}
MockUsage is a mock of Usage interface
func NewMockUsage ¶
func NewMockUsage(ctrl *gomock.Controller) *MockUsage
NewMockUsage creates a new mock instance
func (*MockUsage) EXPECT ¶
func (m *MockUsage) EXPECT() *MockUsageMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockUsageMockRecorder ¶
type MockUsageMockRecorder struct {
// contains filtered or unexported fields
}
MockUsageMockRecorder is the mock recorder for MockUsage
func (*MockUsageMockRecorder) Command ¶
func (mr *MockUsageMockRecorder) Command(cmd, globalFlagsFromEnv, cmdFlagsFromEnv interface{}) *gomock.Call
Command indicates an expected call of Command
func (*MockUsageMockRecorder) Global ¶
func (mr *MockUsageMockRecorder) Global(cmds, flagsFromEnv interface{}) *gomock.Call
Global indicates an expected call of Global
type MockVersion ¶
type MockVersion struct {
// contains filtered or unexported fields
}
MockVersion is a mock of Version interface
func NewMockVersion ¶
func NewMockVersion(ctrl *gomock.Controller) *MockVersion
NewMockVersion creates a new mock instance
func (*MockVersion) EXPECT ¶
func (m *MockVersion) EXPECT() *MockVersionMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockVersion) Metadata ¶
func (m *MockVersion) Metadata() VersionMetadata
Metadata mocks base method
type MockVersionMockRecorder ¶
type MockVersionMockRecorder struct {
// contains filtered or unexported fields
}
MockVersionMockRecorder is the mock recorder for MockVersion
func (*MockVersionMockRecorder) Describe ¶
func (mr *MockVersionMockRecorder) Describe() *gomock.Call
Describe indicates an expected call of Describe
func (*MockVersionMockRecorder) Metadata ¶
func (mr *MockVersionMockRecorder) Metadata() *gomock.Call
Metadata indicates an expected call of Metadata
func (*MockVersionMockRecorder) Version ¶
func (mr *MockVersionMockRecorder) Version() *gomock.Call
Version indicates an expected call of Version
type Usage ¶
type Usage interface { // Global outputs the global usage for an App, based on the provided // command.Cmds and flag.FlagSet Global(cmds []*command.Cmd, flagsFromEnv tbnflag.FromEnv) // Command outputs the usage for the given command.Cmd, including global and // command flags. Command(cmd *command.Cmd, globalFlagsFromEnv tbnflag.FromEnv, cmdFlagsFromEnv tbnflag.FromEnv) }
Usage provides methods to output global and command-specific usage of an App. No specific output format or destination is specified by the interface.
type Version ¶
type Version interface { Describe() string Version() string Metadata() VersionMetadata }
type VersionMetadata ¶
func GetVersionMetadata ¶
func GetVersionMetadata() VersionMetadata
Gets the version metadata for the build. May be useful for forensics.