Repository navigation
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 onlyTo 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_textdecodes 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_bytesgives the bytes back.Run.mainreadsargvthrough
them, so a native app can open a file whose name is not UTF-8 with
File.open_bytes(#66).Run.plannedruns an app whose action is a pureplan(term, value)
returning aCli.Ran{code, out, err}: its exit status and its stdout and
stderr text.Cli.invokereturns theCli.RanthatRun.plannedwrites
and exits with for anargv, so a law can state what the app prints. The
quickstart,examples/helloand the pkg demo now use a plan (#41).Cli.programreads a<COMMAND>...positional withCli.rest()as a
Cli.Program{name, args}, a program and its arguments in one slot, as
timeoutandenvtake them;Cli.program_optreads[COMMAND]...
(#43).Cli.unknown_text(c, path, name, t)renders the errorCli.evalgives 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_oftakes the listIO.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, soretry curl -fsS urlpasses-fsSon
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
buildwith 10,000-Ipairs 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 82printed 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.