cli

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package cli parses specd's raw command-line arguments into Args: a list of positional tokens and a flag map. It has no knowledge of any specific command — that mapping from parsed Args to behavior lives in internal/cmd — so it stays a single-purpose, dependency-free tokenizer shared by every command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args struct {
	Pos   []string
	Flags map[string]string
}

Args holds the parsed command-line arguments for a specd invocation: ordered positional tokens and flag values keyed by flag name (without the leading "--").

func ParseArgs

func ParseArgs(argv []string) Args

ParseArgs splits argv into positional tokens and "--flag"/"--flag=value" entries. A "--flag=value" token binds the value explicitly; a known boolean flag (see booleanFlags) is recorded as "true" without consuming the next token; any other "--flag" consumes the following token as its value unless that token is itself a flag, in which case it is also recorded as "true".

func (Args) Bool

func (a Args) Bool(key string) bool

Bool reports whether the flag key was set to the literal value "true" (the value ParseArgs assigns to boolean and bare flags).

func (Args) Has

func (a Args) Has(key string) bool

Has reports whether flag key was set at all, regardless of its value.

func (Args) Str

func (a Args) Str(key string) string

Str returns the string value of flag key, or "" if the flag was not set.

Jump to

Keyboard shortcuts

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