cliflags

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachFormatFlags

func AttachFormatFlags(cmd *cobra.Command, format *string)

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

func DirOnly(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)

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

func FormatCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL