|
1 | 1 | # Usage |
2 | 2 |
|
3 | | -Usage is a spec, CLI, and Rust framework for defining command-line interfaces. |
4 | | -Arguments, flags, environment variables, and config files can all be described in |
5 | | -a portable KDL spec. Think of it as [OpenAPI](https://www.openapis.org/) for CLIs: |
6 | | -one declaration can drive parsing and every user-facing artifact. |
| 3 | +**Define your CLI once. Generate the tools around it.** |
7 | 4 |
|
8 | | -- Generate shell completions |
9 | | -- Generate Markdown documentation and man pages |
10 | | -- Parse arguments from any language |
11 | | -- Scaffold a spec into CLI frameworks in different languages |
12 | | -- Build a typed Rust CLI with a zero-dependency runtime |
| 5 | +Usage is a portable [KDL](https://kdl.dev/) specification, a command-line utility, |
| 6 | +and a Rust framework. Describe commands, flags, arguments, and settings in one |
| 7 | +place, then use that definition for parsing, help, shell completions, Markdown |
| 8 | +docs, man pages, and typed clients. |
13 | 9 |
|
14 | | -See more at [usage.jdx.dev](https://usage.jdx.dev/). |
| 10 | +[Get started](https://usage.jdx.dev/guide/getting-started) · |
| 11 | +[Rust framework](https://usage.jdx.dev/rust/) · |
| 12 | +[Spec reference](https://usage.jdx.dev/spec/reference/) · |
| 13 | +[CLI reference](https://usage.jdx.dev/cli/reference/) |
| 14 | + |
| 15 | +| Your starting point | How Usage fits | |
| 16 | +| --------------------- | -------------------------------------------------------------------------------------------- | |
| 17 | +| A new Rust CLI | Derive a typed parser and exportable spec from structs and enums. | |
| 18 | +| An existing CLI | [Export a spec](https://usage.jdx.dev/spec/integrations) from your framework, or write KDL. | |
| 19 | +| A script | [Declare arguments in comments](https://usage.jdx.dev/cli/scripts) and let Usage parse them. | |
| 20 | +| Code that calls a CLI | [Generate a TypeScript or Python SDK](https://usage.jdx.dev/cli/sdk). | |
15 | 21 |
|
16 | 22 | ## Rust framework |
17 | 23 |
|
@@ -48,6 +54,46 @@ and value variants. See the [Rust framework guide](https://usage.jdx.dev/rust/) |
48 | 54 | and [clap migration guide](https://usage.jdx.dev/rust/migrating-from-clap) for |
49 | 55 | the supported mappings and intentional differences. |
50 | 56 |
|
| 57 | +## Standalone CLI |
| 58 | + |
| 59 | +Choose one installation method: |
| 60 | + |
| 61 | +```sh |
| 62 | +# mise |
| 63 | +mise use -g usage |
| 64 | + |
| 65 | +# Homebrew |
| 66 | +brew install usage |
| 67 | + |
| 68 | +# Cargo |
| 69 | +cargo install usage-cli --locked |
| 70 | +``` |
| 71 | + |
| 72 | +The package is `usage-cli`; the executable is `usage`. |
| 73 | +[Other installation options](https://usage.jdx.dev/cli/#installation). |
| 74 | + |
| 75 | +With a spec saved as `mycli.usage.kdl`: |
| 76 | + |
| 77 | +```sh |
| 78 | +usage lint mycli.usage.kdl |
| 79 | +usage generate completion zsh mycli --file mycli.usage.kdl --install |
| 80 | +usage generate markdown --file mycli.usage.kdl --out-file reference.md |
| 81 | +usage generate manpage --file mycli.usage.kdl --out-file mycli.1 |
| 82 | +``` |
| 83 | + |
| 84 | +The generated shell scripts need `usage` at completion time. The Rust framework |
| 85 | +can also [provide completions directly](https://usage.jdx.dev/rust/completions) |
| 86 | +from your binary. |
| 87 | + |
| 88 | +Follow the [spec walkthrough](https://usage.jdx.dev/guide/getting-started) for a |
| 89 | +complete example. The [Go framework](https://usage.jdx.dev/go/) is a development |
| 90 | +preview and is not ready for adoption or testing. |
| 91 | + |
| 92 | +## Contributing |
| 93 | + |
| 94 | +See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, checks, and generated |
| 95 | +files. |
| 96 | + |
51 | 97 | ## Sponsors |
52 | 98 |
|
53 | 99 | <p align="center"> |
|
0 commit comments