{"modulePath":"github.com/codeactual/aws-exec-cmd","version":"v0.1.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package handler\n\n## Functions\n\n```go\nfunc Version() string\n```\n\n## Types\n\n```go\ntype DefaultSession struct {\n\t// contains filtered or unexported fields\n}\n```\nDefaultSession can be embedded in all mixins and sub-command handlers and provide a default implementation of the Session interface which uses os.Stdout, os.Stderr, and os.Stdin by default.\n\n```go\nfunc (s *DefaultSession) Err() io.Writer\n```\n\n```go\nfunc (s *DefaultSession) ExitOnErr(err error, msg string, code int)\n```\n\n```go\nfunc (s *DefaultSession) ExitOnErrShort(err error, msg string, code int)\n```\n\n```go\nfunc (s *DefaultSession) ExitOnErrsShort(errs []error, code int)\n```\n\n```go\nfunc (s *DefaultSession) Exitf(code int, format string, a ...interface{})\n```\n\n```go\nfunc (s *DefaultSession) In() io.Reader\n```\n\n```go\nfunc (s *DefaultSession) OnSignal(sig os.Signal, f func(os.Signal)) (cancel func())\n```\n\n```go\nfunc (s *DefaultSession) Out() io.Writer\n```\n\n```go\nfunc (s *DefaultSession) SetErr(w io.Writer)\n```\n\n```go\nfunc (s *DefaultSession) SetIn(r io.Reader)\n```\n\n```go\nfunc (s *DefaultSession) SetOut(w io.Writer)\n```\n\n```go\ntype Input struct {\n\t// Args holds all unbound arguments except for the first \"--\" if present.\n\tArgs []string\n\n\t// ArgsBeforeDash holds the subset of Args located before the first \"--\" if present,\n\t// or the same elements as Args if absent.\n\tArgsBeforeDash []string\n\n\t// ArgsAfterDash holds the subset of Args located after the first \"--\" if present.\n\tArgsAfterDash []string\n}\n```\nInput defines the framework-agnostic user input passed to handler's Run methods.\n\n```go\ntype Mixin interface {\n\t// BindCobraFlags gives each mixin the opportunity to define its own flags.\n\tBindCobraFlags(cmd *cobra.Command) (requiredFlags []string)\n\n\t// Name should identify the mixin for use in error/log messages.\n\t//\n\t// Ideally it is short, e.g. like a package name.\n\tName() string\n}\n```\n\n```go\ntype PostRun interface {\n\tPostRun(ctx context.Context)\n}\n```\nPostRun is optionally implemented by handlers/mixins to perform tasks after Handler.Run finishes.\n\n```go\ntype PreRun interface {\n\tPreRun(ctx context.Context, args []string) error\n}\n```\nPreRun is optionally implemented by handlers/mixins to perform tasks after flags are parsed but before Handler.Run.\n\nIf it returns an error, Handler.Run and Handler.PostRun do not execute.\n\n```go\ntype Session interface {\n\t// Err returns the standard error destination.\n\tErr() io.Writer\n\n\t// In returns the standard input source.\n\tIn() io.Reader\n\n\t// OnSignal starts a goroutine which runs the provided function every time the signal\n\t// is received. It returns a function to end the goroutine.\n\tOnSignal(s os.Signal, do func(os.Signal)) (cancel func())\n\n\t// Out returns the standard output destination.\n\tOut() io.Writer\n\n\t// SetErr assigns the standard error destination.\n\tSetErr(io.Writer)\n\n\t// SetIn assigns the standard input source.\n\tSetIn(io.Reader)\n\n\t// SetOut assigns the standard error destination.\n\tSetOut(io.Writer)\n\n\t// ExitOnError exits the program if the error is non-nil and prints the error in full format (%+v).\n\tExitOnErr(err error, msg string, code int)\n\n\t// ExitOnErrorShort exits the program if the error is non-nil and prints the error's string value.\n\tExitOnErrShort(err error, msg string, code int)\n\n\t// ExitOnErrsShort exits the program if the slice is non-empty and prints each error's string value.\n\tExitOnErrsShort(errs []error, code int)\n\n\t// Exitf exits the program with a formatted message.\n\tExitf(code int, format string, a ...interface{})\n}\n```\nSession defines CLI handler behaviors which are useful to replace with test doubles.\n\nBehaviors related to terminal I/O are based on the interface approach in docker's CLI:\n\n\thttps://github.com/docker/cli/blob/f1b116179f2a95d0ea45780dfb8be51c2825b9c0/cli/command/cli.go\n\thttps://www.apache.org/licenses/LICENSE-2.0.html\n\n","path":"github.com/codeactual/aws-exec-cmd/internal/cage/cli/handler","name":"handler","synopsis":"","isRedistributable":true}
