diff --git a/.github/workflows/publish-cli.yml b/.github/workflows/publish-cli.yml index a939addb..ada3a8ee 100644 --- a/.github/workflows/publish-cli.yml +++ b/.github/workflows/publish-cli.yml @@ -96,4 +96,4 @@ jobs: with: submodules: recursive - uses: jdx/mise-action@v2 - - run: gh release edit ${{ github.ref_name }} --draft=false + - run: gh release edit ${{ github.ref_name }} --draft=#false diff --git a/Cargo.lock b/Cargo.lock index 7bde79f8..c0e4c852 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -268,7 +268,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.96", + "syn", ] [[package]] @@ -304,17 +304,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "contracts" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1d1429e3bd78171c65aa010eabcdf8f863ba3254728dbfb0ad4b1545beac15c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -372,7 +361,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" dependencies = [ "quote", - "syn 2.0.96", + "syn", ] [[package]] @@ -396,7 +385,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.96", + "syn", ] [[package]] @@ -407,7 +396,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.96", + "syn", ] [[package]] @@ -804,13 +793,14 @@ dependencies = [ [[package]] name = "kdl" -version = "4.7.0" +version = "6.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a18038fbecda667e7ea2101bdd02af754da5e17ca2887a7649b8f3fa809d8b8" +checksum = "6d63de1aa3d632a8dd61da7cddfc499e9f88e6265d85bd84002419c3cdd3dc8f" dependencies = [ "miette", - "nom", + "num", "thiserror 1.0.69", + "winnow", ] [[package]] @@ -894,7 +884,7 @@ checksum = "23c9b935fbe1d6cbd1dac857b54a688145e2d93f48db36010514d0f612d0ad67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn", ] [[package]] @@ -940,12 +930,76 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1032,7 +1086,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.96", + "syn", ] [[package]] @@ -1282,7 +1336,7 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn", ] [[package]] @@ -1324,7 +1378,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.96", + "syn", ] [[package]] @@ -1407,7 +1461,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.96", + "syn", ] [[package]] @@ -1431,17 +1485,6 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.96" @@ -1527,7 +1570,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn", ] [[package]] @@ -1538,7 +1581,7 @@ checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn", ] [[package]] @@ -1659,11 +1702,9 @@ dependencies = [ "assert_cmd", "clap", "clap_usage", - "contracts", "ctor", "env_logger", "exec", - "heck", "indexmap 2.7.0", "itertools 0.14.0", "kdl", @@ -1675,7 +1716,6 @@ dependencies = [ "serde", "serde_json", "serde_with", - "strum", "tera", "thiserror 2.0.11", "usage-lib", @@ -1775,7 +1815,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.96", + "syn", "wasm-bindgen-shared", ] @@ -1797,7 +1837,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1884,7 +1924,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn", ] [[package]] @@ -1895,7 +1935,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn", ] [[package]] @@ -1980,6 +2020,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winnow" +version = "0.6.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39281189af81c07ec09db316b302a3e67bf9bd7cbf6c820b50e35fee9c2fa980" +dependencies = [ + "memchr", +] + [[package]] name = "xx" version = "2.0.3" @@ -2019,5 +2068,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn", ] diff --git a/clap_usage/tests/snapshots/simple__simple.snap b/clap_usage/tests/snapshots/simple__simple.snap index 697a44da..d6ca2087 100644 --- a/clap_usage/tests/snapshots/simple__simple.snap +++ b/clap_usage/tests/snapshots/simple__simple.snap @@ -3,10 +3,10 @@ source: clap_usage/tests/simple.rs expression: output snapshot_kind: text --- -name "example" -bin "example" +name example +bin example usage "Usage: example [OPTIONS]" -flag "--file" help="some input file" { - arg "" +flag --file help="some input file" { + arg } -flag "--usage" +flag --usage diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 85d24503..3a53b5a2 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -27,13 +27,11 @@ path = "src/lib.rs" [dependencies] clap = { version = "4", features = ["derive", "string", "env"] } clap_usage = { workspace = true } -contracts = "0.6" env_logger = "0.11" exec = "0.3" -heck = "0.5" indexmap = "2" itertools = "0.14" -kdl = "= 4.7.0" # upgrade when it supports new miette +kdl = "6" log = "0.4" miette = { version = "7", features = ["fancy"] } once_cell = "1" @@ -41,7 +39,6 @@ regex = "1" serde = { version = "1", features = ["derive"] } serde_json = "1.0" serde_with = "3.11" -strum = { version = "0.26", features = ["derive"] } tera = "1" thiserror = "2" usage-lib = { workspace = true, features = ["clap", "docs"] } diff --git a/cli/assets/fig.ts b/cli/assets/fig.ts index 4239e9a9..8fc3b8bd 100644 --- a/cli/assets/fig.ts +++ b/cli/assets/fig.ts @@ -84,262 +84,7 @@ const completionGeneratorTemplate = ( }; const completionSpec: Fig.Spec = { - name: "usage", - subcommands: [ - { - name: "bash", - description: "Executes a bash script", - options: [ - { - name: "-h", - description: "Show help", - isRepeatable: false, - }, - { - name: "--help", - description: "Show help", - isRepeatable: false, - }, - ], - args: [ - { - name: "script", - }, - { - name: "args", - description: "Arguments to pass to script", - isOptional: true, - isVariadic: true, - }, - ], - }, - { - name: ["complete-word", "cw"], - options: [ - { - name: "--shell", - isRepeatable: false, - args: { - name: "shell", - suggestions: ["bash", "fish", "zsh"], - }, - }, - { - name: ["-f", "--file"], - description: "Usage spec file or script with usage shebang", - isRepeatable: false, - args: { - name: "file", - template: "filepaths", - }, - }, - { - name: ["-s", "--spec"], - description: "Raw string spec input", - isRepeatable: false, - args: { - name: "spec", - }, - }, - { - name: "--cword", - description: "Current word index", - isRepeatable: false, - args: { - name: "cword", - }, - }, - ], - args: { - name: "words", - description: "User's input from the command line", - isOptional: true, - isVariadic: true, - }, - }, - { - name: ["generate", "g"], - subcommands: [ - { - name: ["completion", "c"], - options: [ - { - name: "--cache-key", - description: - "A cache key to use for storing the results of calling the CLI with --usage-cmd", - isRepeatable: false, - args: { - name: "cache_key", - }, - }, - { - name: ["-f", "--file"], - description: - "A .usage.kdl spec file to use for generating completions", - isRepeatable: false, - args: { - name: "file", - template: "filepaths", - }, - }, - { - name: "--usage-bin", - description: - "Override the bin used for calling back to usage-cli", - isRepeatable: false, - args: { - name: "usage_bin", - }, - }, - { - name: "--usage-cmd", - description: - 'A command which generates a usage spec e.g.: `mycli --usage` or `mycli completion usage` Defaults to "$bin --usage"', - isRepeatable: false, - args: { - name: "usage_cmd", - }, - }, - { - name: "--include-bash-completion-lib", - description: "Include https://github.com/scop/bash-completion", - isRepeatable: false, - }, - ], - args: [ - { - name: "shell", - suggestions: ["bash", "fish", "zsh"], - }, - { - name: "bin", - description: "The CLI which we're generates completions for", - }, - ], - }, - { - name: "fig", - options: [ - { - name: ["-f", "--file"], - description: "A usage spec taken in as a file", - isRepeatable: false, - args: { - name: "file", - template: "filepaths", - }, - }, - { - name: "--spec", - description: "Raw string spec input", - isRepeatable: false, - args: { - name: "spec", - }, - }, - { - name: "--out-file", - description: "File on where to save the generated Fig spec", - isRepeatable: false, - args: { - name: "out_file", - template: "filepaths", - }, - }, - ], - }, - { - name: "json", - description: "Outputs a usage spec in json format", - options: [ - { - name: ["-f", "--file"], - description: "A usage spec taken in as a file", - isRepeatable: false, - args: { - name: "file", - template: "filepaths", - }, - }, - { - name: "--spec", - description: "Raw string spec input", - isRepeatable: false, - args: { - name: "spec", - }, - }, - ], - }, - { - name: ["markdown", "md"], - options: [ - { - name: ["-f", "--file"], - description: "A usage spec taken in as a file", - isRepeatable: false, - args: { - name: "file", - template: "filepaths", - }, - }, - { - name: ["-m", "--multi"], - description: "Render each subcommand as a separate markdown file", - isRepeatable: false, - }, - { - name: "--url-prefix", - description: "Prefix to add to all URLs", - isRepeatable: false, - args: { - name: "url_prefix", - }, - }, - { - name: "--html-encode", - description: "Escape HTML in markdown", - isRepeatable: false, - }, - { - name: "--replace-pre-with-code-fences", - isRepeatable: false, - }, - { - name: "--out-dir", - description: "Output markdown files to this directory", - isRepeatable: false, - args: { - name: "out_dir", - template: "folders", - }, - }, - { - name: "--out-file", - isRepeatable: false, - args: { - name: "out_file", - template: "filepaths", - }, - }, - ], - }, - ], - }, - ], - options: [ - { - name: "--usage-spec", - description: "Outputs a `usage.kdl` spec for this CLI itself", - isRepeatable: false, - }, - ], - args: { - name: "completions", - description: - "Outputs completions for the specified shell for completing the `usage` CLI itself", - isOptional: true, - }, + name: "", }; export default completionSpec; diff --git a/cli/src/cli/bash.rs b/cli/src/cli/bash.rs index f68a5f97..3cfb3ff2 100644 --- a/cli/src/cli/bash.rs +++ b/cli/src/cli/bash.rs @@ -12,7 +12,7 @@ use usage::Spec; /// /// Typically, this will be called by a script's shebang /// -/// If using `var=true` on args/flags, they will be joined with spaces using `shell_words::join()` +/// If using `var=#true` on args/flags, they will be joined with spaces using `shell_words::join()` /// to properly escape and quote values with spaces in them. #[derive(Debug, Args)] #[clap(disable_help_flag = true, verbatim_doc_comment)] diff --git a/cli/tests/complete_word.rs b/cli/tests/complete_word.rs index 55ac10e6..48d29116 100644 --- a/cli/tests/complete_word.rs +++ b/cli/tests/complete_word.rs @@ -68,7 +68,7 @@ fn complete_word_kitchen_sink() { #[test] fn complete_word_choices() { assert_cmd("mise.usage.kdl", &["--", "env", "--shell", ""]) - .stdout("bash\nfish\nnu\nxonsh\nzsh\n"); + .stdout("bash\nelvish\nfish\nnu\nxonsh\nzsh\npwsh\n"); } #[test] diff --git a/cli/usage.usage.kdl b/cli/usage.usage.kdl index 4f98cb25..45700763 100644 --- a/cli/usage.usage.kdl +++ b/cli/usage.usage.kdl @@ -1,107 +1,102 @@ -name "usage-cli" -bin "usage" +name usage-cli +bin usage version "1.7.4" about "CLI for working with usage-based CLIs" usage "Usage: usage-cli [OPTIONS] [COMPLETIONS] " -flag "--usage-spec" help="Outputs a `usage.kdl` spec for this CLI itself" -arg "[COMPLETIONS]" help="Outputs completions for the specified shell for completing the `usage` CLI itself" required=false -cmd "bash" help="Executes a bash script" { - long_help r"Executes a bash script - -Typically, this will be called by a script's shebang - -If using `var=true` on args/flags, they will be joined with spaces using `shell_words::join()` -to properly escape and quote values with spaces in them." - flag "-h" help="show help" - flag "--help" help="show help" - arg "