Documentation
¶
Overview ¶
Package cliflags holds tiny, dependency-free Cobra flag helpers shared by every tool in the repo (format aliases, etc.). Keeping these in a separate package avoids import cycles with internal/cli (which composes the master CLI tree from the concrete tool commands).
Index ¶
- func AttachFormatFlags(cmd *cobra.Command, format *string)
- func DirOnly(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)
- func ExactArgsHint(n int, hint string) cobra.PositionalArgs
- func FormatCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)
- func MinArgs(n int, hint string) cobra.PositionalArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttachFormatFlags ¶
AttachFormatFlags adds --format (default "toon") plus --md and --json boolean aliases to cmd. Call this from any tool that emits TOON/MD/JSON to keep the flag surface consistent. The resolved format is written to *format via a PreRunE that runs before the command's own RunE.
func DirOnly ¶
DirOnly is a ShellCompDirective shortcut for flags that take a directory. Returning it from RegisterFlagCompletionFunc tells the shell to complete directory names only (no regular files).
func ExactArgsHint ¶
func ExactArgsHint(n int, hint string) cobra.PositionalArgs
ExactArgsHint is like cobra.ExactArgs(n) with the same hint contract as MinArgs: a wrong arg count returns hint verbatim.
func FormatCompletion ¶
FormatCompletion suggests known output formats with short descriptions. Bash and fish render the trailing "\tdescription" as the help column.
func MinArgs ¶
func MinArgs(n int, hint string) cobra.PositionalArgs
MinArgs is like cobra.MinimumNArgs(n) but, on too few args, returns hint verbatim instead of cobra's generic "requires at least N arg(s)". hint should be a parsable "<what>; try: <command>" string (no "error:" prefix — main() adds it) so the agent self-corrects in the same turn instead of burning one on a bare usage error.
Types ¶
This section is empty.