Skip to content

0.2.0.0

Latest

Choose a tag to compare

@viridale viridale released this 29 Oct 00:29
· 4 commits to main since this release

bend-cli 0.2.0.0, published on BendHub as cli@0.2.0.0
(0xa67b4e5d151887b6bff62a913c86b60d). It requires Bend 2.0.39 or newer.

import cli@0.2.0.0/cli.bend as Cli   # application logic and laws
import cli@0.2.0.0/run.bend as Run   # the IO entry point only

To upgrade, change both imports. Run.main and Run.planned read argv as
bytes themselves; only code that calls Run.argv_of directly must now pass it
the list IO.args_bytes() answers.

Added

  • Cli.arg_text decodes an argument's bytes, turning each byte that starts
    no well-formed UTF-8 sequence into U+DC00 plus the byte (PEP 383), and
    Cli.arg_bytes gives the bytes back. Run.main reads argv through
    them, so a native app can open a file whose name is not UTF-8 with
    File.open_bytes (#66).
  • Run.planned runs an app whose action is a pure plan(term, value)
    returning a Cli.Ran{code, out, err}: its exit status and its stdout and
    stderr text. Cli.invoke returns the Cli.Ran that Run.planned writes
    and exits with for an argv, so a law can state what the app prints. The
    quickstart, examples/hello and the pkg demo now use a plan (#41).
  • Cli.program reads a <COMMAND>... positional with Cli.rest() as a
    Cli.Program{name, args}, a program and its arguments in one slot, as
    timeout and env take them; Cli.program_opt reads [COMMAND]...
    (#43).
  • Cli.unknown_text(c, path, name, t) renders the error Cli.eval gives an
    unknown subcommand, with similar names and usage, so an app with
    Cli.external() can report a name that no plugin answers to (#44).

Changed

  • Bend 2.0.39 or newer is required.
  • Run.argv_of takes the list IO.args_bytes() answers instead of
    IO.args()'s.
  • A Cli.rest() positional's first value may start with -, as a
    Cli.hyphen() positional's may, so retry curl -fsS url passes -fsS on
    instead of failing on -f (#42).
  • A Cli.hyphen() positional takes a long token that names no option, such
    as --x=1, as it takes -x.
  • A huge argv parses faster: argbench's build with 10,000 -I pairs and
    as many inputs takes 42.8 ms in a native app, where 0.1.0.0 took 59.8
    (median wall time on an Apple M3 Max; README, Performance).

Output changes

  • In a native app, an argument cut short in the middle of a UTF-8 sequence
    prints one U+FFFD for each of its bytes: E2 82 printed one before and
    prints two now. Compiled JavaScript is unchanged.

Before 1.0.0.0, a minor release may include breaking changes; see the
README's Upgrading section.