Documentation
¶
Overview ¶
Package cli provides common I/O utilities for md-tools binaries.
Index ¶
Constants ¶
const Version = "1.2.1"
Version is the md-tools release version. Bumped by scripts/release.
Variables ¶
This section is empty.
Functions ¶
func Input ¶
func Input(args []string) (io.ReadCloser, error)
Input returns a reader for the tool's input. If file arguments are provided, it opens and concatenates them. Otherwise, it returns stdin. Per the CLI contract: if both stdin and file arguments are provided, file arguments take precedence.
func Run ¶
func Run(toolName string, flags *Flags, args []string, transform TransformFunc) error
Run executes a CLI tool with the standard md-tools interface. It dispatches on the parsed flags: -v prints the version; -w writes the result back to each file argument; -i reads stdin and writes the result to the single file argument. The default reads from files (or stdin) and writes to stdout.
Types ¶
type Flags ¶
Flags holds the standard md-tools flags. Register them with RegisterFlags before flag.Parse(), then pass the populated struct to Run.
func RegisterFlags ¶
func RegisterFlags() *Flags
RegisterFlags registers -w, -i, -v, and -version on the default flag set and returns a Flags whose fields are populated by flag.Parse().
type TransformFunc ¶
TransformFunc is a function that transforms input content to output content.