Skip to content

v7.5.0: Declare environment variables with an `env` node; faster spec loading

Latest

Choose a tag to compare

@github-actions github-actions released this 01 Dec 09:34
Immutable release. Only release title and notes can be modified.
50e035d

Specs can now declare the environment variables a command reads with a new env node. This release also makes Tab completion offer flags instead of file names when no positional argument is left, and loads large specs much faster.

Added

  • (spec) A new env node declares an environment variable that a command reads but that isn't the value of any flag (#1689). Put it inside a cmd for a variable that command reads, or at the top level for one the whole program reads. Proposed in discussion #1688.

    cmd "shell" help="Open a shell in the worktree" {
      env "SHELL" help="The program to open" default_note="bash"
    }
    • Markdown docs list the variable under Environment on the command's page. Man pages list it in the command's section, and top-level variables get an ENVIRONMENT section.
    • usage generate json includes it as envs on the command.
    • unknown_env treats it as declared, including when it is hidden.
    • usage lint adds two rules: missing-env-help (info) and duplicate-env (error).

    The node supports help, long_help, default_note, deprecated and hide. It only documents the variable: usage never reads it or applies the default, and subcommands don't inherit it. Library users get a new SpecEnv type and a SpecCommand::envs field. The Rust derives don't emit env nodes yet, so for now you have to declare them in KDL.

Fixed

  • (complete) complete-word no longer offers file names when the command takes no more positional arguments and has no subcommands (#1681). Pressing Tab on an empty word now lists the command's flags. A word that doesn't start with -, or any word after --, gets no candidates. For example, mise run <task> <Tab> for a task that has only flags now shows those flags instead of the current folder. Thanks to @roalcantara for reporting it in #1679.

Performance

  • (spec) Large specs load faster, which speeds up every Tab completion (#1683, #1684). The KDL parser is about 3x faster and produces the same results and errors as before. Global flags are also no longer copied into every command during spec loading. On mise's spec, completing mise use <Tab> takes about 57% fewer instructions.

Full Changelog: v7.4.1...v7.5.0

💚 Sponsor usage

usage is built and maintained by @jdx, an open source developer at entire.io, the title sponsor of his open source work.

If usage powers CLI specs, docs, or completions for a tool you maintain or use, please consider becoming an individual or company sponsor. Your support funds ongoing development and helps keep usage fast, free, and independent.