cmdl

package
v0.0.0-...-337ae54 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2025 License: 0BSD Imports: 17 Imported by: 0

Documentation

Overview

Package cmdl provides a command-line interface linker for runtime.link.

Function Tags

Tags can be added to functions to indicate how arguments should be mapped to command-line arguments. Each space seperated component will be passed as a seperate argument to the command-line. A component may contain a format placeholder ('%v' or '%[n]v').

Struct Tags

Tags can be added to fields to indicate how they should be packed and unpacked from os.Args. Rules behave simarly to function tags, command line parameters are included by default unless they are a bool without a format parameter or are flagged as 'omitempty'. Field tags can additionally specify one of the subsequent flags:

  • 'env' variable.

  • 'dir' sets the working directory.

  • 'invert' bool (and the behaviour of omitempty).

The documentation of a field tag will be used for the help text. If a field is a io.Reader it will be passed to stdin, io.Writer will be passed to stdout by default unless the field is tagged with `cmdl:",stderr"`.

Index

Constants

This section is empty.

Variables

View Source
var API api.Linker[string, *exec.Cmd] = linker{}

API implements the api.Linker interface.

Functions

func Main

func Main(program any)

Execute is the entry point for a command-line interface.

Types

type System

type System struct {
	Dir string // equivalent to os.Getwd()

	Args    []string  // equivalent to os.Args
	Environ []string  // equivalent to os.Environ()
	Stdin   io.Reader // equivalent to os.Stdin
	Stdout  io.Writer // equivalent to os.Stdout
	Stderr  io.Writer // equivalent to os.Stderr

	FS fs.FS // equivalent to os.DirFS()
}

func (System) Output

func (os System) Output(program any) ([]byte, error)

func (System) Run

func (os System) Run(program any) error

Jump to

Keyboard shortcuts

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