cli

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT-0 Imports: 4 Imported by: 0

Documentation

Overview

Package cli provides common I/O utilities for md-tools binaries.

Index

Constants

View Source
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

type Flags struct {
	WriteInPlace bool
	InPlace      bool
	ShowVersion  bool
}

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

type TransformFunc func(string) string

TransformFunc is a function that transforms input content to output content.

Jump to

Keyboard shortcuts

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