❯ rotini --documentation█

Rotini v1.5.0 has been released, together with new releases of every go-rotini package it uses.

New

  • Local and cascading flags. A flag now applies only to its own command unless it is cascading: true, which makes it apply to its command and every command below, as help’s “Global Flags” already described it. Given anywhere else, a local flag is a usage error that says where it belongs (--init belongs to "app", not "app db migrate"). Its required, group and dependency rules apply only when its command runs, and completion follows the same scope. Env and config values are not affected. See commands, flags and arguments.
  • Prefixed integers. base: prefixed on an integer input accepts 0x1F, 0o17 and 0b101, with a sign and _ between digits, from every source, defaults and enums included. Help notes it, the contract and JSON Schemas describe it, and rotini diff rates adding it safe. See times, patterns and negated forms.
  • Your own metadata. metadata: is a map of strings on commands, flags, arguments, env, config and stdin, for your own tools. It’s copied into the generated definitions and the contract as written, and shown on no page. See your own metadata.
  • Streams of several kinds. output_stream: true with output: {oneOf: [...]} streams items of several kinds, each naming itself in one shared tag. The generated code gives you a sealed interface only those kinds satisfy, WriteOutputItem fills in the tag, DecodeOutput and rotinitest.Output decode each item into its kind, and output checks check each item. See streams of several kinds.
  • Completion fallback per request. rtx.SetCompletionFallback lets a completer choose what the shell falls back to for one request, so an argument can offer remote names when some match and local paths otherwise. Completion scripts generated by v1.4 already understand it. See completers.
  • Smaller and faster. A typical generated CLI is 3.36 MB stripped, down from 3.84 MB, and a process run adds 0.33 ms over a plain Go program, down from 0.38 ms. In process, a run takes 9.1 µs and 57 allocations, down from 23.4 µs and 329, and printing help takes 3.0 µs. A config file is read and decoded once per inputs read, schema check included, and a program with env or config inputs allocates about 60% less per run. See what a program links.

Changed

  • Flags are local unless they cascade. Mark cascading: true on every flag users give with a sub-command. A root --help or --version seeded before v1.3 isn’t cascading, so <command> --help becomes a usage error until you mark it; validate and generate warn about it.
  • Integers from env and config files are decimal. PORT=0x10 is an invalid value and 010 reads as ten, unless the input declares base: prefixed. Bounds are checked on every such value.
  • Config files are stricter. A repeated key in a YAML or JSON config file or stdin document fails, as does a second YAML document, and an unreadable config file is an error even when it’s optional. A null config value (mode:, ~) counts as not set, so it no longer overrides a flag or a default. A comment-only file loads as empty.
  • Completion scripts. Every shell now inserts candidates exactly as given, quotes included, and bash works under bash 5.2 and in a shell running with set -e. Regenerate and reinstall your completion scripts.
  • validate and generate check more. New errors for Go identifier and file name clashes, Windows device names and Go keyword package names; new warnings for multi-line summaries and an env variable two inputs read differently.
  • rotini -v is gone; the companion answers --version only, as rotini init seeds it.
  • Windows paths in messages are quoted as typed: "C:\Users\me", not "C:\\Users\\me".
  • OutputDef is no longer comparable with ==, since it gained the kinds of a multi-kind stream.

Upgrading from v1.4

Bump github.com/go-rotini/rotini and the rotini tool to v1.5.0, raise version: in your spec and conf to 1.5.0, and run rotini generate. Then:

  1. Mark cascading: true on each flag your users give with a sub-command, including a root --help or --version seeded before v1.3. rotini validate lists the ones it can tell.
  2. Add base: prefixed to any integer input whose env or config values use 0x, 0o or 0b.
  3. Regenerate and reinstall your completion scripts.
  4. Update tests that match Windows paths in messages, or that compare OutputDef values with ==.
  5. Run rotini validate: a few specs v1.4 accepted are now errors, and it says which.

See upgrading for the general steps.