Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/cli/completions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Generating Completion Scripts

::: tip Building with usage-rs or usage-go?
Both frameworks generate and answer completions from the tables compiled into your binary, so
there is no spec file to ship and no `usage` runtime dependency for your users. See
[Rust completions](/rust/completions) and [Go completions](/go/completions). This page covers
generating scripts with the `usage` CLI from a `.usage.kdl` spec or a `usage`-shebang script.
:::

## Auto-completion for shebang scripts (bash)

If you have shell scripts that use the `usage` shebang
Expand Down
26 changes: 16 additions & 10 deletions docs/rust/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@
Used by some of jdx's CLIs, but point releases may break.
:::

`usage-rs` is a fast, typed framework for building complete command-line applications in Rust.
`usage-rs` is a CLI framework for Rust applications, and the reference implementation of the
[usage spec](/spec/). It is fully featured — more of what a real CLI needs than clap offers —
and its parser is up to thousands of times faster.

Declare commands, flags, arguments, and settings with familiar structs and enums, and get
first-class environment and config-file resolution, advanced shell completions, portable
validation, negation flags, typed argument groups, categorized subcommands, and more.

In the mise-scale benchmark it parses hundreds of times faster than clap, with no third-party
runtime crates and a 1.3 MB stripped binary versus clap's 3.1 MB. See the
[performance results](/rust/performance) and [clap migration guide](/rust/migrating-from-clap).

The same declaration also becomes a portable [usage spec](/spec/) that the binary can print.
`usage-cli` turns it into documentation, manpages, and completions — the same toolchain used
across jdx's CLIs.
validation, negation flags, typed argument groups, categorized subcommands, and more. The derive
accepts most clap spellings, so a migration is largely mechanical.

The speed comes from where the work happens: the derive lays the command tree out as static
tables while your application compiles, so a parse never builds and validates a parser the way
clap and bpaf do on every run. At mise scale that is 855x fewer instructions than clap and
2,957x fewer than bpaf, in a 1.3 MB stripped binary against clap's 3.1 MB, with no third-party
crates linked into your binary. See the [performance results](/rust/performance) and
[clap migration guide](/rust/migrating-from-clap).

The same declaration also becomes a portable spec that the binary can print. `usage-cli` turns
it into documentation, manpages, and completions — the same toolchain used across jdx's CLIs.

```rust
use usage::Cli;
Expand Down
8 changes: 5 additions & 3 deletions docs/rust/performance.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Parser performance

usage's compiled Rust parser is designed so ordinary argv parsing reads static
tables and writes directly into the result. Cold metadata for help, specs, and
completions is not constructed on a successful parse.
`usage-rs` has the fastest argument parser of the Rust frameworks measured here:
at mise scale it parses in 0.7 µs, 855x fewer instructions than clap and 2,957x
fewer than bpaf. The derive lays the command tree out as static tables while
your application compiles, so a parse reads what the compiler already built
instead of constructing and validating a parser on every run.

## Mise-scale result

Expand Down