Documentation ¶
Index ¶
- Constants
- Variables
- func BugReport() string
- func Context(ctx context.Context, name string, debug bool, logLevel string) (context.Context, context.CancelFunc)
- func DirectWriter(w io.Writer) func(context.Context) (io.Writer, error)
- func DiscardWriter() func(context.Context) (io.Writer, error)
- func Examples(s string) string
- func Expand(path string) (string, error)
- func FileReader(filename string) func(context.Context) (io.Reader, error)
- func FileWriter(filename string) func(context.Context) (io.Writer, error)
- func HandlePluginCommand(pluginHandler PluginHandler, cmdArgs []string) error
- func LineReader(name string) ([]string, error)
- func LongDesc(s string) string
- func NewClosedWriter() io.WriteCloser
- func NewTimeoutReader(reader io.Reader, timeout time.Duration) io.Reader
- func ReadSecret(prompt string, confirmation bool) (*memguard.LockedBuffer, error)
- func Reader(name string) (io.Reader, error)
- func StdoutWriter() func(context.Context) (io.Writer, error)
- func Writer(name string) (io.Writer, error)
- type DefaultPluginHandler
- type PluginHandler
- type TimeoutReader
Constants ¶
const ( // MaxReaderLimitSize is the upper limit for reader capability. MaxReaderLimitSize = 250 * 1024 * 1024 // ReaderTimeout is a time limit during the reader is waiting for data. ReaderTimeout = 1 * time.Minute )
const Indentation = ` `
Variables ¶
var ErrNoHome = errors.New("no home found")
ErrNoHome is raised when tilde expansion failed.
Functions ¶
func Context ¶
func Context(ctx context.Context, name string, debug bool, logLevel string) (context.Context, context.CancelFunc)
Context initializes a command context.
func DirectWriter ¶ added in v0.2.1
DirectWriter returns the given writer.
func DiscardWriter ¶ added in v0.2.1
DiscardWriter returns discard writer.
func FileReader ¶
FileReader returns lazy evaluated reader.
func FileWriter ¶
FileWriter returns lazy evaluated writer.
func HandlePluginCommand ¶
func HandlePluginCommand(pluginHandler PluginHandler, cmdArgs []string) error
HandlePluginCommand receives a pluginHandler and command-line arguments and attempts to find a plugin executable on the PATH that satisfies the given arguments.
func LineReader ¶
LineReader creates a reder and returns content read line by line.
func LongDesc ¶ added in v0.2.8
LongDesc normalizes a command's long description to follow the conventions.
func NewClosedWriter ¶ added in v0.2.1
func NewClosedWriter() io.WriteCloser
NewClosedWriter returns a io.WriteCloser instance which always fails when writing data. (Used for testing purpose).
func NewTimeoutReader ¶
NewTimeoutReader create a timed-out limited reader instance.
func ReadSecret ¶
func ReadSecret(prompt string, confirmation bool) (*memguard.LockedBuffer, error)
ReadSecret reads password from Stdin and returns a lockedbuffer.
func Reader ¶
Reader creates a reader instance according to the given name value Use "" or "-" for Stdin reader, else use a filename.
func StdoutWriter ¶
StdoutWriter returns lazy evaluated writer.
Types ¶
type DefaultPluginHandler ¶
type DefaultPluginHandler struct {
ValidPrefixes []string
}
DefaultPluginHandler implements PluginHandler
func NewDefaultPluginHandler ¶
func NewDefaultPluginHandler(validPrefixes []string) *DefaultPluginHandler
NewDefaultPluginHandler instantiates the DefaultPluginHandler with a list of given filename prefixes used to identify valid plugin filenames.
type PluginHandler ¶
type PluginHandler interface { // exists at the given filename, or a boolean false. // Lookup will iterate over a list of given prefixes // in order to recognize valid plugin filenames. // The first filepath to match a prefix is returned. Lookup(filename string) (string, bool) // Execute receives an executable's filepath, a slice // of arguments, and a slice of environment variables // to relay to the executable. Execute(executablePath string, cmdArgs, environment []string) error }
PluginHandler is capable of parsing command line arguments and performing executable filename lookups to search for valid plugin files, and execute found plugins.
type TimeoutReader ¶
type TimeoutReader struct {
// contains filtered or unexported fields
}
TimeoutReader implemnts a timelimited reader.