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"). Itsrequired, 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: prefixedon an integer input accepts0x1F,0o17and0b101, with a sign and_between digits, from every source, defaults and enums included. Help notes it, the contract and JSON Schemas describe it, androtini diffrates 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: truewithoutput: {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,WriteOutputItemfills in the tag,DecodeOutputandrotinitest.Outputdecode each item into its kind, and output checks check each item. See streams of several kinds. - Completion fallback per request.
rtx.SetCompletionFallbacklets 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: trueon every flag users give with a sub-command. A root--helpor--versionseeded before v1.3 isn’t cascading, so<command> --helpbecomes a usage error until you mark it;validateandgeneratewarn about it. - Integers from env and config files are decimal.
PORT=0x10is an invalid value and010reads as ten, unless the input declaresbase: 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. validateandgeneratecheck 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 -vis gone; the companion answers--versiononly, asrotini initseeds it.- Windows paths in messages are quoted as typed:
"C:\Users\me", not"C:\\Users\\me". OutputDefis 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:
- Mark
cascading: trueon each flag your users give with a sub-command, including a root--helpor--versionseeded before v1.3.rotini validatelists the ones it can tell. - Add
base: prefixedto any integer input whose env or config values use0x,0oor0b. - Regenerate and reinstall your completion scripts.
- Update tests that match Windows paths in messages, or that compare
OutputDefvalues with==. - Run
rotini validate: a few specs v1.4 accepted are now errors, and it says which.
See upgrading for the general steps.