Documentation
¶
Overview ¶
Package cli builds the cobra command tree and maps errors to exit codes.
Index ¶
- Constants
- func Execute(ctx context.Context, d *app.Deps, args []string) int
- func FlagKeys() map[string]string
- func Main(ctx context.Context, d *app.Deps, args []string) int
- func NewRootCmd(d *app.Deps) *cobra.Command
- func Run(ctx context.Context, args []string, stdout, stderr io.Writer) int
- func ServeMCP(ctx context.Context, d *app.Deps, args []string, ...) error
- func SplitAnnotation(cmd *cobra.Command, key string) []string
- type ExitCode
Constants ¶
const ( AnnotationFormats = "formats" // --format values the command accepts; empty means it ignores --format AnnotationFailOn = "fail-on" // --fail-on values AnnotationExitCodes = "exit-codes" // exit codes the command returns AnnotationRelated = "docs.related" // site paths of related guides and concepts )
Command annotations that scripts/gendocs reads. Values are comma-separated lists.
const ( ExitOK = 0 ExitError = 1 ExitUsage = 2 ExitFindings = 3 // --fail-on matched ExitAuth = 4 ExitInterrupted = 130 )
Exit codes. ExitCodes describes each one for the docs site.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
Execute runs the command line in args (without the program name) and returns the exit code.
func Main ¶ added in v0.2.0
Main is Execute for a whole process. It also answers carapace's completion requests, which changes package-level state, so in-process tests call Execute instead.
func NewRootCmd ¶
NewRootCmd returns the full command tree. scripts/gendocs uses it.