Documentation ¶
Index ¶
- Constants
- Variables
- func AtLeastArgs(min int) func(cmd *cobra.Command, args []string) error
- func ExactArgs(num int) func(cmd *cobra.Command, args []string) error
- func Exit(code int)
- func FlagErrorFunc(cmd *cobra.Command, err error) error
- func GetToken(server string) string
- func NewClientConn(addr string, token string, skipVerify bool) (*grpc.ClientConn, error)
- func NoArgs(cmd *cobra.Command, args []string) error
- func OnExit(f func())
- func RangeArgs(min int, max int) func(cmd *cobra.Command, args []string) error
- func ReadClientConfig(config *Configuration) error
- func ReadOrg(server string) (string, error)
- func ReadTeam(server string) (string, error)
- func ReadToken(server string) (string, error)
- func RemoveFile(server string) error
- func RemoveToken(server string) error
- func SaveOrg(org string, server string) error
- func SaveTeam(team string, server string) error
- func SaveToken(headers metadata.MD, server string) error
- func SetupRootCommand(rootCmd *cobra.Command)
- type Configuration
- type Console
- func (c *Console) Error(args ...interface{})
- func (c *Console) Errorf(format string, args ...interface{})
- func (c *Console) Errorln(args ...interface{})
- func (c *Console) Fatal(args ...interface{})
- func (c *Console) Fatalf(format string, args ...interface{})
- func (c *Console) Fatalln(args ...interface{})
- func (c *Console) GetInput(prompt string) (in string)
- func (c *Console) GetSilentInput(prompt string) (in string)
- func (c *Console) Info(args ...interface{})
- func (c *Console) Infof(format string, args ...interface{})
- func (c *Console) Infoln(args ...interface{})
- func (c *Console) OutStream() *OutStream
- func (c *Console) Print(args ...interface{})
- func (c *Console) Printf(format string, args ...interface{})
- func (c *Console) Println(args ...interface{})
- func (c *Console) SetTheme(theme *Theme)
- func (c *Console) SetThemeName(name string)
- func (c *Console) Success(args ...interface{})
- func (c *Console) Successf(format string, args ...interface{})
- func (c *Console) Successln(args ...interface{})
- func (c *Console) Theme() *Theme
- func (c *Console) Warn(args ...interface{})
- func (c *Console) Warnf(format string, args ...interface{})
- func (c *Console) Warnln(args ...interface{})
- type Errors
- type InStream
- type Interface
- type Logger
- func (l Logger) Fatal(args ...interface{})
- func (l Logger) Fatalf(format string, args ...interface{})
- func (l Logger) Fatalln(args ...interface{})
- func (l Logger) OutStream() *OutStream
- func (l Logger) Print(args ...interface{})
- func (l Logger) Printf(format string, args ...interface{})
- func (l Logger) Println(args ...interface{})
- func (l Logger) Verbose() bool
- type LoginCredentials
- type OutStream
- type Preferences
- type StatusError
- type Theme
Constants ¶
const ( // DefaultAddress for amp connection DefaultAddress = "localhost" // DefaultPort for amp connection DefaultPort = configuration.DefaultPort )
const (
//Credentials suffix for authentication token file
Credentials = ".credentials"
)
const (
// Padding for tabwriter
Padding = 3
)
Variables ¶
var ( // DarkTheme defines colors appropriate for a dark terminal DarkTheme = &Theme{ Normal: color.New(), Info: color.New(color.FgHiBlack), Warn: color.New(color.FgYellow), Error: color.New(color.FgRed), Success: color.New(color.FgGreen), } // LightTheme defines colors appropriate for a light terminal LightTheme = &Theme{ Normal: color.New(), Info: color.New(color.FgBlack), Warn: color.New(color.FgYellow), Error: color.New(color.FgRed), Success: color.New(color.FgGreen), } )
Functions ¶
func AtLeastArgs ¶ added in v0.9.1
AtLeastArgs returns an error if the min number of args are not passed
func Exit ¶
func Exit(code int)
Exit ensures that any registered functions are executed before exiting with the specified status code.
func FlagErrorFunc ¶
FlagErrorFunc prints an error message which matches the format of the docker/docker/cli error messages
func NewClientConn ¶
NewClientConn is a helper function that wraps the steps involved in setting up a grpc client connection to the API.
func OnExit ¶
func OnExit(f func())
OnExit is used to register functions that should be executed upon exiting.
func RangeArgs ¶ added in v0.9.1
RangeArgs returns an error if the min and max number of args are not passed
func ReadClientConfig ¶ added in v0.10.0
func ReadClientConfig(config *Configuration) error
ReadClientConfig reads the CLI configuration
func RemoveFile ¶ added in v0.12.0
RemoveFile removes the preferences file from the .config folder
func RemoveToken ¶
RemoveToken deletes the authentication token file
func SetupRootCommand ¶
SetupRootCommand sets default usage, help, and error handling for the root command.
Types ¶
type Configuration ¶
Configuration is for all configurable client settings
type Console ¶
type Console struct { Logger // contains filtered or unexported fields }
Console augments basic logging functions with a theme that can be applied for various standardized CLI output functions, such as Success and Error.
func NewConsole ¶
NewConsole creates a CLI Console instance that writes to the provided stream.
func (*Console) Error ¶
func (c *Console) Error(args ...interface{})
Error prints args using Theme.Error().
func (*Console) Errorln ¶
func (c *Console) Errorln(args ...interface{})
Errorln prints args using Theme.Error() and appends a newline.
func (*Console) Fatal ¶
func (c *Console) Fatal(args ...interface{})
Fatal prints args Theme.Error() and exits with code 1.
func (*Console) Fatalln ¶
func (c *Console) Fatalln(args ...interface{})
Fatalln prints args using Theme.Error(),appends a newline and exits with code 1
func (*Console) GetSilentInput ¶
GetSilentInput gets input from standard input, without displaying characters, and returns it
func (*Console) Info ¶
func (c *Console) Info(args ...interface{})
Info prints args using Theme.Info().
func (*Console) Infoln ¶
func (c *Console) Infoln(args ...interface{})
Infoln prints args using Theme.Info() and appends a newline.
func (*Console) Print ¶
func (c *Console) Print(args ...interface{})
Print prints args using Theme.Normal().
func (*Console) Println ¶
func (c *Console) Println(args ...interface{})
Println prints args using Theme.Normal() and appends a newline.
func (*Console) SetThemeName ¶
SetThemeName sets the console theme by name.
func (*Console) Success ¶
func (c *Console) Success(args ...interface{})
Success prints args Theme.Success().
func (*Console) Successln ¶
func (c *Console) Successln(args ...interface{})
Successln prints args using Theme.Success() and appends a newline.
func (*Console) Warn ¶
func (c *Console) Warn(args ...interface{})
Warn prints args using Theme.Warn().
type Errors ¶
type Errors []error
Errors is a list of errors. Useful in a loop if you don't want to return the error right away and you want to display after the loop, all the errors that happened during the loop.
type InStream ¶
type InStream struct {
// contains filtered or unexported fields
}
InStream is an input stream used by the DockerCli to read user input
func NewInStream ¶
func NewInStream(in io.ReadCloser) *InStream
NewInStream returns a new InStream object from a ReadCloser
func (*InStream) CheckTty ¶
CheckTty checks if we are trying to attach to a container tty from a non-tty client input stream, and if so, returns an error.
func (*InStream) IsTerminal ¶
IsTerminal returns true if this stream is connected to a terminal
func (*InStream) RestoreTerminal ¶
func (i *InStream) RestoreTerminal()
RestoreTerminal restores normal mode to the terminal
func (*InStream) SetRawTerminal ¶
SetRawTerminal sets raw mode on the input terminal
type Interface ¶
type Interface interface { Version() string Build() string Console() *Console In() *InStream Out() *OutStream Err() io.Writer ShowHelp(cmd *cobra.Command, args []string) error Server() string SetServer(server string) SetSkipVerify(skipVerify bool) Connect() (*grpc.ClientConn, error) ClientConn() *grpc.ClientConn OnInitialize(initializers ...func()) }
Interface for the CLI's functionality.
func NewCLI ¶
func NewCLI(in io.ReadCloser, out, err io.Writer, config *Configuration) Interface
NewCLI returns a new CLI instance.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a simple logger for the AMP CLI that also implements grpclog.Logger
func (Logger) Fatal ¶
func (l Logger) Fatal(args ...interface{})
Fatal is equivalent to fmt.Print() followed by a call to os.Exit(1).
func (Logger) Fatalln ¶
func (l Logger) Fatalln(args ...interface{})
Fatalln is equivalent to fmt.Println() followed by a call to os.Exit(1).
func (Logger) Print ¶
func (l Logger) Print(args ...interface{})
Print is equivalent to fmt.Print() if verbose mode. Arguments are handled in the manner of fmt.Printf.
type LoginCredentials ¶
type LoginCredentials struct {
Token string
}
LoginCredentials represents login credentials
func (*LoginCredentials) GetRequestMetadata ¶
func (c *LoginCredentials) GetRequestMetadata(context.Context, ...string) (map[string]string, error)
GetRequestMetadata implements credentials.PerRPCCredentials
func (*LoginCredentials) RequireTransportSecurity ¶
func (c *LoginCredentials) RequireTransportSecurity() bool
RequireTransportSecurity implements credentials.PerRPCCredentials
type OutStream ¶
type OutStream struct {
// contains filtered or unexported fields
}
OutStream is an output stream used by the Cli to write normal program output.
func NewOutStream ¶
NewOutStream returns a new OutStream object from a Writer
func (*OutStream) GetTtySize ¶
GetTtySize returns the height and width in characters of the tty
func (*OutStream) IsTerminal ¶
IsTerminal returns true if this stream is connected to a terminal
func (*OutStream) RestoreTerminal ¶
func (o *OutStream) RestoreTerminal()
RestoreTerminal restores normal mode to the terminal
func (*OutStream) SetRawTerminal ¶
SetRawTerminal sets raw mode on the output terminal
type Preferences ¶ added in v0.12.0
type StatusError ¶
StatusError reports an unsuccessful exit by a command.
func (StatusError) Error ¶
func (e StatusError) Error() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
command
|
|
completion
Copied from https://raw.githubusercontent.com/kubernetes/kubernetes/master/pkg/kubectl/cmd/completion.go
|
Copied from https://raw.githubusercontent.com/kubernetes/kubernetes/master/pkg/kubectl/cmd/completion.go |