Documentation
¶
Overview ¶
Package cli is the `zn` command surface: the same commands, flags, output and JSON shapes as the CLI the desktop app bundles, plus `zn tui`.
Index ¶
- Variables
- func DeriveTitle(body string) string
- func FindDesktopApp() (string, error)
- func Main(argv []string) int
- func OpenBackend(target backend.Target) (backend.Backend, error)
- func ReadStdin() string
- func RenderHelp(argv []string) string
- func RenderVersion(argv []string) string
- func ResolveTargetFromArgs(args Args) (backend.Target, error)
- func TagCounts(notes []vault.NoteMeta) []tagCount
- type Args
- func (a Args) Bool(name string) bool
- func (a Args) Int(name string) (int, bool)
- func (a Args) IntOr(name string, fallback int) int
- func (a Args) Many(name string) []string
- func (a Args) Positional(n int) string
- func (a Args) ResolveBody(fallbackPositional string) *string
- func (a Args) Str(name string) string
- func (a Args) String(name string) (string, bool)
- type Handler
Constants ¶
This section is empty.
Variables ¶
var Version = defaultVersion
Version is what `zn --version` and the help banner print.
Functions ¶
func DeriveTitle ¶
DeriveTitle is the first non-empty line, stripped of its leading marker and capped at 60 characters, so a captured `- [ ] buy milk` titles the note "buy milk" while the marker stays in the body.
func FindDesktopApp ¶
FindDesktopApp locates the ZenNotes desktop executable. ZENNOTES_APP_PATH wins; then the usual install locations per platform; then PATH.
func OpenBackend ¶
OpenBackend binds a target with the user's portable preferences applied.
func RenderHelp ¶
RenderHelp is the pretty `zn --help`, colors gated on TTY detection and the NO_COLOR / FORCE_COLOR conventions.
func ResolveTargetFromArgs ¶
ResolveTargetFromArgs picks the vault for an invocation from the global flags.
Types ¶
type Args ¶
Args is a parsed command line: positionals plus repeated flags.
zn <command> [<subcommand>] [positional...] [--flag value | --flag=value | -x value]
Repeated flags collect in order. Boolean flags are inferred when no value follows or when the next token starts with `--`.
func Parse ¶
Parse mirrors the desktop CLI's parser, including its one subtlety: only a dash followed by a letter is a short flag, so `zn capture "- [ ] task"` keeps its task line positional.
func (Args) Positional ¶
Positional is the nth positional or "".
func (Args) ResolveBody ¶
ResolveBody applies the body conventions: `--body "literal"`, `--body -` (stdin), a positional fallback, then piped stdin; nil when nothing.