{"modulePath":"github.com/weakpixel/engine","version":"v0.0.0-20261205071607-94fff0387040","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cli\n\nPackage cli is what the Cobra command trees of the wpix binaries share: the exit codes (0 ok, 1 failure, 2 usage), the error type that means a usage error, and the version command. Tool packages import only [UsageError](#UsageError) and [Usagef](#Usagef) from here; Cobra stays in the cmd packages.\n\n## Constants\n\n```go\nconst (\n\tExitOK      = 0\n\tExitFailure = 1\n\tExitUsage   = 2\n)\n```\nExit codes of every wpix binary.\n\n## Functions\n\n```go\nfunc AddVersion(root *cobra.Command)\n```\nAddVersion gives root the version command and the --version flag, which both print [Version](#Version) alone.\n\n```go\nfunc Args(v cobra.PositionalArgs) cobra.PositionalArgs\n```\nArgs wraps a Cobra argument validator so its error is a [UsageError](#UsageError).\n\n```go\nfunc Execute(root *cobra.Command, stderr io.Writer) int\n```\nExecute runs root and returns the exit code: 0 on success, 2 for a [UsageError](#UsageError), a flag that does not parse, a wrong argument count or a missing required flag, 1 for any other error. An error is printed to stderr as \"\\\u003ccommand path\u003e: \\\u003cerror\u003e\", without the usage text. Output of --help goes where the caller pointed root.SetOut, stdout by default.\n\n```go\nfunc Group(cmd *cobra.Command) *cobra.Command\n```\nGroup makes cmd a command that only has subcommands: with no subcommand it prints its help to stderr and is a usage error, with an unknown one it is a usage error naming it.\n\n```go\nfunc NewVersionCmd(binary string) *cobra.Command\n```\nNewVersionCmd is the version command of binary.\n\n```go\nfunc Usagef(format string, args ...any) error\n```\nUsagef returns a [UsageError](#UsageError) with a formatted message. A tool package returns it for a usage problem only the tool can detect.\n\n```go\nfunc Version() string\n```\nVersion is the module version of the binary: a release or pseudo-version when installed with go install or go run pkg@version, \"(devel)\" from a checkout.\n\n## Types\n\n```go\ntype UsageError struct{ Msg string }\n```\nUsageError is an error that makes the command exit with [ExitUsage](#ExitUsage): the command line was wrong, not the work it did.\n\n```go\nfunc (e *UsageError) Error() string\n```\n\n","path":"github.com/weakpixel/engine/tools/internal/cli","name":"cli","synopsis":"Package cli is what the Cobra command trees of the wpix binaries share: the exit codes (0 ok, 1 failure, 2 usage), the error type that means a usage error, and the version command.","isRedistributable":true}
