carapace_spec_clap-1.1.0/.cargo_vcs_info.json0000644000000001610000000000100146010ustar { "git": { "sha1": "cbefd7d2276231166af672018b034c3a41435849", "dirty": true }, "path_in_vcs": "" }carapace_spec_clap-1.1.0/.github/FUNDING.yml000064400000000000000000000001241046102023000165450ustar 00000000000000# These are supported funding model platforms github: [rsteube] polar: carapace-sh carapace_spec_clap-1.1.0/.github/ISSUE_TEMPLATE/bug_report.yaml000064400000000000000000000021541046102023000221540ustar 00000000000000name: Bug description: File a bug/issue title: "" labels: [bug, fund] body: - type: textarea attributes: label: Current Behavior description: A concise description of what you're experiencing. validations: required: false - type: textarea attributes: label: Expected Behavior description: A concise description of what you expected to happen. validations: required: false - type: textarea attributes: label: Steps To Reproduce description: Steps to reproduce the behavior. placeholder: | 1. In this environment... 2. With this config... 3. Run '...' 4. See error... validations: required: false - type: input attributes: label: Version description: Version where this occured. validations: required: false - type: textarea attributes: label: Anything else? description: | Links? References? Anything that will give us more context about the issue you are encountering! Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. validations: required: false ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/.github/ISSUE_TEMPLATE/request.yaml����������������������������������������0000644�0000000�0000000�00000001317�10461020230�0021474�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: Request description: Submit a request title: "<title>" labels: [enhancement, fund] body: - type: textarea attributes: label: Request description: Describe the feature or problem you’d like to solve. validations: required: false - type: textarea attributes: label: Proposed solution description: How will it benefit the project and its users. validations: required: false - type: textarea attributes: label: Anything else? description: | Links? References? Anything that will give us more context about the request! Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. validations: required: false �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/.github/dependabot.yml�����������������������������������������������������0000644�0000000�0000000�00000000155�10461020230�0017564�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������version: 2 updates: - package-ecosystem: "cargo" directory: "/" schedule: interval: "weekly" �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/.github/workflows/rust.yml�������������������������������������������������0000644�0000000�0000000�00000001713�10461020230�0020512�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: Rust on: pull_request: push: env: CARGO_TERM_COLOR: always jobs: build: runs-on: ubuntu-latest steps: - name: shallow clone uses: actions/checkout@v4 - name: deep clone uses: actions/checkout@v4 if: startsWith(github.ref, 'refs/tags/v') with: fetch-depth: 0 - name: Build run: cargo build --verbose - name: Run tests run: cargo test --verbose - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 if: startsWith(github.ref, 'refs/tags/v') with: version: latest args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish crate if: startsWith(github.ref, 'refs/tags/v') run: sed -i "s_0.1.0-PLACEHOLDER_${GITHUB_REF/refs\/tags\/v/}_" Cargo.toml && cargo publish --token ${CRATES_TOKEN} --allow-dirty env: CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} �����������������������������������������������������carapace_spec_clap-1.1.0/.gitignore�����������������������������������������������������������������0000644�0000000�0000000�00000000010�10461020230�0015352�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/target ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/.goreleaser.yml������������������������������������������������������������0000644�0000000�0000000�00000000027�10461020230�0016323�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������builds: - skip: true ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/Cargo.lock�����������������������������������������������������������������0000644�����������������00000020614�00000000001�0012561�0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "anstream" version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", "utf8parse", ] [[package]] name = "anstyle" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ "windows-sys", ] [[package]] name = "anstyle-wincon" version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys", ] [[package]] name = "carapace_spec_clap" version = "1.1.0" dependencies = [ "clap", "clap_complete", "indexmap", "serde", "serde_yaml_ng", "snapbox", ] [[package]] name = "clap" version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" dependencies = [ "anstyle", "clap_lex", ] [[package]] name = "clap_complete" version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "205d5ef6d485fa47606b98b0ddc4ead26eb850aaa86abfb562a94fb3280ecba0" dependencies = [ "clap", ] [[package]] name = "clap_lex" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "equivalent" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" [[package]] name = "hashbrown" version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" [[package]] name = "indexmap" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown", "serde", ] [[package]] name = "itoa" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "normalize-line-endings" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "proc-macro2" version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] name = "ryu" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "serde" version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_yaml_ng" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b4db627b98b36d4203a7b458cf3573730f2bb591b28871d916dfa9efabfd41f" dependencies = [ "indexmap", "itoa", "ryu", "serde", "unsafe-libyaml", ] [[package]] name = "similar" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62ac7f900db32bf3fd12e0117dd3dc4da74bc52ebaac97f39668446d89694803" [[package]] name = "snapbox" version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "840b73eb3148bc3cbc10ebe00ec9bc6d96033e658d022c4adcbf3f35596fd64a" dependencies = [ "anstream", "anstyle", "normalize-line-endings", "similar", "snapbox-macros", ] [[package]] name = "snapbox-macros" version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16569f53ca23a41bb6f62e0a5084aa1661f4814a67fa33696a79073e03a664af" dependencies = [ "anstream", ] [[package]] name = "syn" version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "unicode-ident" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] name = "unsafe-libyaml" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "utf8parse" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" ��������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/Cargo.toml�����������������������������������������������������������������0000644�����������������00000003024�00000000001�0012600�0����������������������������������������������������������������������������������������������������ustar ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "carapace_spec_clap" version = "1.1.0" build = false autobins = false autoexamples = false autotests = false autobenches = false description = "spec generation for clap-rs/clap" readme = "README.md" keywords = [ "cli", "completion", "clap", "carapace", ] categories = ["command-line-interface"] license = "MIT" repository = "https://github.com/carapace-sh/carapace-spec-clap" [lib] name = "carapace_spec_clap" path = "src/lib.rs" [[example]] name = "carapace_spec" path = "examples/carapace_spec.rs" [[example]] name = "git" path = "examples/git.rs" [[test]] name = "carapace_spec" path = "tests/carapace_spec.rs" [[test]] name = "common" path = "tests/common.rs" [dependencies.clap] version = "4.5.17" features = ["std"] default-features = false [dependencies.clap_complete] version = "4.5.26" [dependencies.indexmap] version = "2.5.0" features = ["serde"] [dependencies.serde] version = "1.0" features = ["derive"] [dependencies.serde_yaml_ng] version = "0.10.0" [dev-dependencies.snapbox] version = "0.6" features = ["diff"] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/Cargo.toml.orig������������������������������������������������������������0000644�0000000�0000000�00000001173�10461020230�0016264�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������[package] name = "carapace_spec_clap" description = "spec generation for clap-rs/clap" version = "1.1.0" edition = "2021" repository = "https://github.com/carapace-sh/carapace-spec-clap" license = "MIT" categories = ["command-line-interface"] keywords = ["cli", "completion", "clap", "carapace"] [lib] [dependencies] clap = { version = "4.5.17", default-features = false, features = ["std"] } clap_complete = { version = "4.5.26" } indexmap = {version = "2.5.0", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } serde_yaml_ng = "0.10.0" [dev-dependencies] snapbox = { version = "0.6", features = ["diff"] } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/LICENSE��������������������������������������������������������������������0000644�0000000�0000000�00000002050�10461020230�0014375�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������MIT License Copyright (c) 2022 rsteube Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/README.md������������������������������������������������������������������0000644�0000000�0000000�00000005015�10461020230�0014653�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# carapace-spec-clap [![Crates.io](https://img.shields.io/crates/v/carapace_spec_clap.svg)](https://crates.io/crates/carapace_spec_clap) [Spec](https://github.com/carapace-sh/carapace-spec) generation for [clap-rs/clap](https://github.com/clap-rs/clap) [![asciicast](https://asciinema.org/a/548145.svg)](https://asciinema.org/a/548145) ```rust use carapace_spec_clap::Spec; use clap::{Arg, ArgAction, Command, ValueHint}; use clap_complete::generate; use std::io; fn main() { let mut cmd = Command::new("example") .aliases(["alias1", "alias2"]) .about("example command") .arg( Arg::new("help") .long("help") .short('h') .help("show help") .action(ArgAction::SetTrue), ) .arg( Arg::new("optional") .long("optional") .help("optional argument") .require_equals(true) .value_hint(ValueHint::Username), ) .arg( Arg::new("value") .short('v') .help("takes argument") .value_parser(["one", "two", "three"]), ) .subcommand( Command::new("subcommand") .about("example subcommand") .arg( Arg::new("command") .long("command") .short('c') .help("execute command") .value_hint(ValueHint::CommandName), ) .arg( Arg::new("pos1") .value_parser(["four", "five", "six"]) .value_hint(ValueHint::DirPath), ) .arg( Arg::new("posAny") .num_args(1..) .value_hint(ValueHint::Hostname), ), ); generate(Spec, &mut cmd, "example", &mut io::stdout()); } ``` ```yaml name: example aliases: - alias1 - alias2 description: example command flags: -h, --help: show help --optional?: optional argument -v=: takes argument completion: flag: optional: - $_os.Users v: - one - two - three commands: - name: subcommand description: example subcommand flags: -c, --command=: execute command completion: flag: command: - $_os.PathExecutables - $files positional: - - $directories - four - five - six positionalany: - $_net.Hosts ``` �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/dist/CHANGELOG.md����������������������������������������������������������0000644�0000000�0000000�00000017066�10461020230�0016161�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������## Changelog * cbefd7d2276231166af672018b034c3a41435849 Merge pull request #219 from carapace-sh/fix-release * 4d51a331e09ac466d79482553b0f6b8bdfd0f937 fix release * 0b2ba87adacfbc7cc2d51078d676d899c39dfe3b Merge pull request #218 from carapace-sh/replace-serde_yaml * 406036005ef4e08b4e91282c23266985fc9ae125 replaced `serde_yaml` with `serde_yaml_ng` * a77d8dd9c3ae1854c77bf1a084cad4f688f14876 Merge pull request #217 from carapace-sh/fix-value-hints * c9295480292b62a71ce298935786a08dc258a1b5 fix value hints * 704775e992a7336784ed38afac1d714a40c90e86 Merge pull request #170 from carapace-sh/dependabot/cargo/serde_yaml-0.9.34deprecated * aba0243d66045e739beff1ca5b63d39fc1e54ca1 Merge pull request #205 from carapace-sh/dependabot/cargo/snapbox-0.6.17 * 843fb5653644bb49aacca51c4068e21628a80c05 fix tests * bb5b686d10820913d6549c6cb9d9b3c42e7c6470 Merge pull request #213 from carapace-sh/dependabot/cargo/serde-1.0.210 * 4c82952a59f927675196f3e1a20ae6e5e0449a8d Bump serde from 1.0.209 to 1.0.210 * 984318b7dbbd490ee8059f2edfaabf71a96c1129 Merge pull request #214 from carapace-sh/dependabot/cargo/clap-4.5.17 * 92e5130f3a613bc640f2492a1a158b1c6adf9627 Bump clap from 4.5.16 to 4.5.17 * 8643d60992f8b4e15d314a459ab67790653def72 Merge pull request #215 from carapace-sh/dependabot/cargo/clap_complete-4.5.26 * ab44324045fa68493cdd5755985249494656ecc1 Bump clap_complete from 4.5.24 to 4.5.26 * 05c6e806ac80931c8ff154c960e3e13ab8df926e Merge pull request #212 from carapace-sh/dependabot/cargo/clap_complete-4.5.24 * 8d2f832a4460ecb3476e5f383f84c5700eb2a477 Merge pull request #209 from carapace-sh/dependabot/cargo/serde-1.0.209 * 89f2a65a016a4a4ebac0e51fea948ad908cc889f Bump serde from 1.0.208 to 1.0.209 * 3f9e423871ab8b5a3267f5055ca0792ef3a38960 Bump clap_complete from 4.5.13 to 4.5.24 * 1b1913bbdfbc4c741df4d8cb9130063b86f01643 Merge pull request #211 from carapace-sh/dependabot/cargo/indexmap-2.5.0 * 760e630bef2f3bca622e920246b503d80582f35a Bump indexmap from 2.4.0 to 2.5.0 * 60f46c19f589e603bc34be41ee355ef2dc0749c4 Merge pull request #206 from carapace-sh/dependabot/cargo/serde-1.0.208 * 172fef1c76c92ff0f815eb5ed85c72b2f2942142 Merge pull request #207 from carapace-sh/dependabot/cargo/indexmap-2.4.0 * d2161d871fc878cd772262d0de23ad15830f1ce3 Bump indexmap from 2.3.0 to 2.4.0 * a49c1ed0136ffa52bbbe44f124757b9505b298f1 Bump serde from 1.0.206 to 1.0.208 * 2c9cefe1952d7453532b82eedb56117ceeef0510 Merge pull request #208 from carapace-sh/dependabot/cargo/clap-4.5.16 * 85bfd8cbdce8cf77ae8fb57880fc1a26e7fcf40a Bump clap from 4.5.15 to 4.5.16 * aba58fd1ff1ecc779858a157511ed7938ff85850 Bump snapbox from 0.4.17 to 0.6.17 * 8b0adf73627346505e994677070c5f956cabd85b Merge pull request #202 from carapace-sh/dependabot/cargo/clap-4.5.15 * eaf24f8925b4baf41f60face1d74a8a524bea0cb Bump clap from 4.5.13 to 4.5.15 * 3b3333b2cbf3872f1c09ee7917f27450b1b779d8 Merge pull request #203 from carapace-sh/dependabot/cargo/clap_complete-4.5.13 * fbec0e7eed3f0b4154d39c44667eb027e2c84dab Merge pull request #204 from carapace-sh/dependabot/cargo/serde-1.0.206 * 1f630d4841c2bc5c81d2de7fbb30b582c643992f Bump serde from 1.0.204 to 1.0.206 * fcdad3cf9893815b0ba183dd0a52aa7fa58676da Bump clap_complete from 4.5.12 to 4.5.13 * f94d0a221c9bd03f33f82bb96fe58d2a58dfee71 Merge pull request #200 from carapace-sh/dependabot/cargo/clap_complete-4.5.12 * b716cbc7f96fec002bd40ff2d0fa4eadc9c91aed Bump clap_complete from 4.5.8 to 4.5.12 * 5b693b787e90fcb8c3f3e2c544e653a39300fe1f Merge pull request #199 from carapace-sh/dependabot/cargo/clap-4.5.13 * 971c0f73ab7dd7700411183783320e5994994673 Merge pull request #201 from carapace-sh/dependabot/cargo/indexmap-2.3.0 * 7730b3b24bd50f0061a723b56e0b302c7ed7d295 Bump indexmap from 2.2.6 to 2.3.0 * 8a8798c7d3b7ccb73c7a3502b098f1536c08d11c Bump clap from 4.5.11 to 4.5.13 * cf3538aab6567cfc55bd0fecb081f0ad19e5d926 Merge pull request #197 from carapace-sh/dependabot/cargo/clap-4.5.11 * 6c71aec050231825f9919b57cb7adf020a7e36c4 Bump clap from 4.5.9 to 4.5.11 * d5c094c6dda73184e76a02c42779fe1137c44d59 Merge pull request #196 from carapace-sh/add-templates * 9b606a0c95689bc8faf19fb0a0ffd2896731c9f0 added templates * f068faac7d7bf8e1836fd1c12a63b27f35353bea Merge pull request #193 from carapace-sh/dependabot/cargo/clap_complete-4.5.8 * 52207f2e1a1c8c4cfb8dbd081b9dcdbc458eab71 Bump clap_complete from 4.5.7 to 4.5.8 * 92fe709a7fd42381493b22a0366f3f0633c71bb6 Merge pull request #195 from carapace-sh/dependabot/cargo/clap-4.5.9 * 00f551590fe321e30e5a59f4cda0a65daaf740fa Bump clap from 4.5.8 to 4.5.9 * eb539e4c54613531ba0fd58741a819aa966fc222 Merge pull request #192 from carapace-sh/dependabot/cargo/serde-1.0.204 * f0b335fcecd2b07122d4dd438d6754beb4a6e44c Bump serde from 1.0.203 to 1.0.204 * b95f732710cd0335dca2d88982e139002f68b774 Merge pull request #190 from carapace-sh/dependabot/cargo/clap_complete-4.5.7 * f52f2831f22fce8d58c5e8d768ea1dea52ea2b2d Bump clap_complete from 4.5.6 to 4.5.7 * 1f930d6135798a7373b77774cb08314d8e33640c Merge pull request #191 from carapace-sh/dependabot/cargo/clap-4.5.8 * 4c89971b4e966a82782f88ec5ba6a13961e76eed Bump clap from 4.5.7 to 4.5.8 * 29355064207ca4a6b11bc6101cead5e089a0b1bc Merge pull request #189 from carapace-sh/dependabot/cargo/clap_complete-4.5.6 * c84589c4fe3ac4fae6041147dd8ed2399e1b8200 Bump clap_complete from 4.5.5 to 4.5.6 * 7caa3625b1c6b3d0fab0ec9992b7b34d074912a1 Merge pull request #180 from carapace-sh/dependabot/cargo/serde-1.0.203 * 351b7ff22add7bbc10b1dc9504e7991837832e68 Bump serde from 1.0.202 to 1.0.203 * fa5d5e4df456aff1d5bbfe9e1dd4af208773828d Merge pull request #186 from carapace-sh/dependabot/cargo/clap_complete-4.5.5 * 7e8c7c735b3c44295834a5cd1f5e7f7f1a78b513 Bump clap_complete from 4.5.2 to 4.5.5 * 7966655c16d0c8e70066121fb529ad7db92fee63 Merge pull request #187 from carapace-sh/dependabot/cargo/clap-4.5.7 * e54a04f648dd5e1291691f16c5f01715ecdee859 Bump clap from 4.5.6 to 4.5.7 * 71df26ac49d9c1c17eda1f93a2cf274ce7c57e4c Merge pull request #183 from carapace-sh/dependabot/cargo/clap-4.5.6 * 415acdc0bb923e7480a537f91b45fc36271942eb Bump clap from 4.5.4 to 4.5.6 * c69b76762dc906d2b1a43d134dd42380aa0dc9b4 Merge pull request #178 from carapace-sh/dependabot/cargo/serde-1.0.202 * fa259ff7678eb4dead9d548183779233a0e4e1e6 Bump serde from 1.0.201 to 1.0.202 * c8d886b1a560175ec8c071e4621d5d1f3103244c Merge pull request #177 from carapace-sh/dependabot/cargo/serde-1.0.201 * a02dc4a0ceac2db176f32d755a0fc9a118842d32 Bump serde from 1.0.200 to 1.0.201 * 177d240c359c2eb4602c90ef22ff9b0a9e16bcc6 Merge pull request #176 from carapace-sh/dependabot/cargo/serde-1.0.200 * 6c3540d0a2b3accca27cb9a6f3a6727ac35cc4e1 Bump serde from 1.0.199 to 1.0.200 * c1fcfcd7df099d08f36b5384ec5c8222c869e66b Merge pull request #175 from carapace-sh/dependabot/cargo/serde-1.0.199 * e8e69437ccc6ada8244a2219cf4f157eb0fcbdc8 Bump serde from 1.0.198 to 1.0.199 * d39f24305c3988419a926967d8ee37a9e2f7d306 Merge pull request #174 from carapace-sh/dependabot/cargo/serde-1.0.198 * c354a326f12dfffc6d5c89b8bbc2f978864b4403 Bump serde from 1.0.197 to 1.0.198 * 69b977e0acce1fe29aefcbc5ee1836ae3cc67f8f Bump serde_yaml from 0.9.32 to 0.9.34+deprecated * 10a146d3c07e391cfe71310a5900a80c0d7125a8 Merge pull request #173 from carapace-sh/dependabot/cargo/clap_complete-4.5.2 * b2d6a037cf38de3b30245f94cb53dd3b5f29ffaa Bump clap_complete from 4.5.1 to 4.5.2 * 931c461e7aa49960e5c71055c942f333eba0c10a Merge pull request #172 from carapace-sh/dependabot/cargo/clap-4.5.4 * 93785913fb3a0286c42e6f4ab69655debf23acd3 Bump clap from 4.5.2 to 4.5.4 * 0e7f3762defd82791e4916257721d77192c1c3bd Merge pull request #171 from carapace-sh/dependabot/cargo/indexmap-2.2.6 * 0878407b06dabc74139423a19b75bf8da55fc3d7 Bump indexmap from 2.2.5 to 2.2.6 ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/dist/artifacts.json��������������������������������������������������������0000644�0000000�0000000�00000000133�10461020230�0017206�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������[{"name":"metadata.json","path":"dist/metadata.json","internal_type":30,"type":"Metadata"}]�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/dist/config.yaml�����������������������������������������������������������0000644�0000000�0000000�00000007473�10461020230�0016502�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������project_name: carapace-spec-clap release: github: owner: carapace-sh name: carapace-spec-clap name_template: '{{.Tag}}' builds: - id: carapace-spec-clap goos: - linux - darwin - windows goarch: - amd64 - arm64 - "386" goarm: - "6" gomips: - hardfloat goamd64: - v1 targets: - linux_amd64_v1 - linux_arm64 - linux_386 - darwin_amd64_v1 - darwin_arm64 - windows_amd64_v1 - windows_arm64 - windows_386 dir: . main: . binary: carapace-spec-clap builder: go skip: "true" gobinary: go command: build ldflags: - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser archives: - id: default name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}' format: tar.gz files: - src: license* - src: LICENSE* - src: readme* - src: README* - src: changelog* - src: CHANGELOG* snapshot: version_template: '{{ .Version }}-SNAPSHOT-{{ .ShortCommit }}' checksum: name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt' algorithm: sha256 changelog: format: '{{ .SHA }}: {{ .Message }} ({{ with .AuthorUsername }}@{{ . }}{{ else }}{{ .AuthorName }} <{{ .AuthorEmail }}>{{ end }})' dist: dist env_files: github_token: ~/.config/goreleaser/github_token gitlab_token: ~/.config/goreleaser/gitlab_token gitea_token: ~/.config/goreleaser/gitea_token source: name_template: '{{ .ProjectName }}-{{ .Version }}' format: tar.gz gomod: gobinary: go announce: twitter: message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' mastodon: message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' server: "" reddit: title_template: '{{ .ProjectName }} {{ .Tag }} is out!' url_template: '{{ .ReleaseURL }}' slack: message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' username: GoReleaser discord: message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' author: GoReleaser color: "3888754" icon_url: https://goreleaser.com/static/avatar.png teams: title_template: '{{ .ProjectName }} {{ .Tag }} is out!' message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' color: '#2D313E' icon_url: https://goreleaser.com/static/avatar.png smtp: subject_template: '{{ .ProjectName }} {{ .Tag }} is out!' body_template: 'You can view details from: {{ .ReleaseURL }}' mattermost: message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' title_template: '{{ .ProjectName }} {{ .Tag }} is out!' username: GoReleaser linkedin: message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' telegram: message_template: '{{ mdv2escape .ProjectName }} {{ mdv2escape .Tag }} is out{{ mdv2escape "!" }} Check it out at {{ mdv2escape .ReleaseURL }}' parse_mode: MarkdownV2 webhook: message_template: '{ "message": "{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}"}' content_type: application/json; charset=utf-8 opencollective: title_template: '{{ .Tag }}' message_template: '{{ .ProjectName }} {{ .Tag }} is out!<br/>Check it out at <a href="{{ .ReleaseURL }}">{{ .ReleaseURL }}</a>' bluesky: message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' git: tag_sort: -version:refname github_urls: download: https://github.com gitlab_urls: download: https://gitlab.com �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/dist/metadata.json���������������������������������������������������������0000644�0000000�0000000�00000000346�10461020230�0017014�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{"project_name":"carapace-spec-clap","tag":"v1.1.0","previous_tag":"v1.0.0","version":"1.1.0","commit":"cbefd7d2276231166af672018b034c3a41435849","date":"2024-09-15T12:00:52.786497167Z","runtime":{"goos":"linux","goarch":"amd64"}}������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/examples/carapace_spec.rs��������������������������������������������������0000644�0000000�0000000�00000003173�10461020230�0020334�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������use carapace_spec_clap::Spec; use clap::{Arg, ArgAction, Command, ValueHint}; use clap_complete::generate; use std::io; fn main() { let mut cmd = Command::new("example") .aliases(["alias1", "alias2"]) .about("example command") .arg( Arg::new("help") .long("help") .short('h') .help("show help") .action(ArgAction::SetTrue), ) .arg( Arg::new("optional") .long("optional") .help("optional argument") .require_equals(true) .value_hint(ValueHint::Username), ) .arg( Arg::new("value") .short('v') .help("takes argument") .value_parser(["one", "two", "three"]), ) .subcommand( Command::new("subcommand") .about("example subcommand") .arg( Arg::new("command") .long("command") .short('c') .help("execute command") .value_hint(ValueHint::CommandName), ) .arg( Arg::new("pos1") .value_parser(["four", "five", "six"]) .value_hint(ValueHint::DirPath), ) .arg( Arg::new("posAny") .num_args(1..) .value_hint(ValueHint::Hostname), ), ); generate(Spec, &mut cmd, "example", &mut io::stdout()); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/examples/git.rs������������������������������������������������������������0000644�0000000�0000000�00000004123�10461020230�0016342�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������use carapace_spec_clap::Spec; use clap::{arg, Command}; use clap_complete::generate; use std::io; use std::path::PathBuf; fn git_cmd() -> Command { Command::new("git") .about("A fictional versioning CLI") .subcommand_required(true) .arg_required_else_help(true) .allow_external_subcommands(true) .subcommand( Command::new("clone") .about("Clones repos") .arg(arg!(<REMOTE> "The remote to clone")) .arg_required_else_help(true), ) .subcommand( Command::new("diff") .about("Compare two commits") .arg(arg!(base: [COMMIT])) .arg(arg!(head: [COMMIT])) .arg(arg!(path: [PATH]).last(true)) .arg( arg!(--color <WHEN>) .value_parser(["always", "auto", "never"]) .num_args(0..=1) .require_equals(true) .default_value("auto") .default_missing_value("always"), ), ) .subcommand( Command::new("push") .about("pushes things") .arg(arg!(<REMOTE> "The remote to target")) .arg_required_else_help(true), ) .subcommand( Command::new("add") .about("adds things") .arg_required_else_help(true) .arg(arg!(<PATH> ... "Stuff to add").value_parser(clap::value_parser!(PathBuf))), ) .subcommand( Command::new("stash") .args_conflicts_with_subcommands(true) .args(push_args()) .subcommand(Command::new("push").args(push_args())) .subcommand(Command::new("pop").arg(arg!([STASH]))) .subcommand(Command::new("apply").arg(arg!([STASH]))), ) } fn push_args() -> Vec<clap::Arg> { vec![arg!(-m --message <MESSAGE>)] } fn main() { let mut cmd = git_cmd(); generate(Spec, &mut cmd, "myapp", &mut io::stdout()); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/src/carapace_spec.rs�������������������������������������������������������0000644�0000000�0000000�00000016743�10461020230�0017314�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������use clap::{ Arg, ArgAction, ValueHint::{self, *}, }; use clap_complete::*; use indexmap::IndexMap as Map; use serde::Serialize; fn default<T: Default + PartialEq>(t: &T) -> bool { *t == Default::default() } #[derive(Default, Serialize)] pub struct Command { pub name: String, #[serde(skip_serializing_if = "Vec::is_empty")] pub aliases: Vec<String>, pub description: String, #[serde(skip_serializing_if = "default")] pub hidden: bool, #[serde(skip_serializing_if = "Map::is_empty")] pub flags: Map<String, String>, #[serde(skip_serializing_if = "Map::is_empty")] pub persistentflags: Map<String, String>, #[serde(skip_serializing_if = "Completion::is_empty")] pub completion: Completion, #[serde(skip_serializing_if = "Vec::is_empty")] pub commands: Vec<Command>, } #[derive(Default, Serialize)] pub struct Completion { #[serde(skip_serializing_if = "Map::is_empty")] pub flag: Map<String, Vec<String>>, #[serde(skip_serializing_if = "Vec::is_empty")] pub positional: Vec<Vec<String>>, #[serde(skip_serializing_if = "Vec::is_empty")] pub positionalany: Vec<String>, #[serde(skip_serializing_if = "Vec::is_empty")] pub dash: Vec<Vec<String>>, #[serde(skip_serializing_if = "Vec::is_empty")] pub dashany: Vec<String>, } impl Completion { pub fn is_empty(&self) -> bool { self.flag.is_empty() && self.positionalany.is_empty() && self.positionalany.is_empty() && self.dash.is_empty() && self.dashany.is_empty() } } pub struct Spec; impl Generator for Spec { fn file_name(&self, name: &str) -> String { format!("{}.yaml", name) } fn generate(&self, cmd: &clap::Command, buf: &mut dyn std::io::Write) { let command = command_for(cmd, true); let serialized = serde_yaml_ng::to_string(&command).unwrap(); buf.write_all(serialized.as_bytes()) .expect("Failed to write to generated file"); } } fn command_for(cmd: &clap::Command, root: bool) -> Command { Command { name: cmd.get_name().to_owned(), aliases: cmd.get_all_aliases().map(String::from).collect(), description: cmd.get_about().unwrap_or_default().to_string(), hidden: cmd.is_hide_set(), flags: flags_for(cmd, false), persistentflags: if let true = root { flags_for(cmd, true) } else { Default::default() }, completion: Completion { flag: flag_completions_for(cmd), positional: positional_completion_for(cmd), positionalany: positionalany_completion_for(cmd), ..Default::default() }, commands: cmd .get_subcommands() .filter(|c| !c.is_hide_set()) .map(|c| command_for(c, false)) .collect(), ..Default::default() } } fn flags_for(cmd: &clap::Command, persistent: bool) -> Map<String, String> { let mut m = Map::new(); let mut arguments = cmd .get_arguments() .filter(|o| !o.is_positional()) .filter(|o| !o.is_hide_set()) .filter(|o| o.is_global_set() == persistent) .map(|x| x.to_owned()) .collect::<Vec<Arg>>(); arguments.sort_by_key(|o| { o.get_long() .unwrap_or(&o.get_short().unwrap_or_default().to_string()) .to_owned() }); for arg in arguments { let signature = if let Some(long) = arg.get_long() { if let Some(short) = arg.get_short() { format!("-{}, --{}", short, long) } else { format!("--{}", long) } } else { format!("-{}", arg.get_short().unwrap()) }; m.insert( format!("{}{}", signature, modifier_for(&arg)), arg.get_help().unwrap_or_default().to_string(), ); } m } fn positionalany_completion_for(cmd: &clap::Command) -> Vec<String> { let mut positionals = cmd.get_positionals().collect::<Vec<&Arg>>(); positionals.sort_by_key(|a| a.get_index()); if let Some(last) = positionals.last() { if last.get_num_args().unwrap_or_default().max_values() == usize::MAX { // TODO different way to detect unboundend? return action_for(last.get_value_hint()) .into_iter() .chain(values_for(last)) .collect::<Vec<String>>(); } } vec![] } fn positional_completion_for(cmd: &clap::Command) -> Vec<Vec<String>> { let mut positionals = cmd.get_positionals().collect::<Vec<&Arg>>(); positionals.sort_by_key(|a| a.get_index()); positionals .into_iter() .filter(|p| p.get_num_args().unwrap_or_default().max_values() != usize::MAX) // filter last vararg pos (added to positionalany) .map(|p| { action_for(p.get_value_hint()) .into_iter() .chain(values_for(p)) .collect::<Vec<String>>() }) .collect() } fn flag_completions_for(cmd: &clap::Command) -> Map<String, Vec<String>> { let mut m = Map::new(); let mut options = cmd .get_opts() .filter(|o| !o.is_positional()) .filter(|o| !o.is_hide_set()) .map(|x| x.to_owned()) .collect::<Vec<Arg>>(); options.sort_by_key(|o| { o.get_long() .unwrap_or(&o.get_short().unwrap_or_default().to_string()) .to_owned() }); for option in options { let name = option .get_long() .unwrap_or(&option.get_short().unwrap_or_default().to_string()) .to_owned(); let action = action_for(option.get_value_hint()) .into_iter() .chain(values_for(&option)) .collect::<Vec<String>>(); if !action.is_empty() { m.insert(name, action); } } m } fn values_for(option: &Arg) -> Vec<String> { let mut v = Vec::new(); if let Some(values) = generator::utils::possible_values(option) { for value in values { if let Some(description) = value.get_help() { v.push(format!("{}\t{}", value.get_name(), description)); } else { v.push(value.get_name().to_owned()); } } } v } fn modifier_for(option: &Arg) -> String { let mut modifier = vec![]; if option.get_action().takes_values() { if option.is_hide_set() { modifier.push("&") } if option.is_required_set() { modifier.push("!") } if option.is_require_equals_set() { modifier.push("?"); } else { modifier.push("="); } } if let ArgAction::Append | ArgAction::Count = option.get_action() { modifier.push("*"); } modifier.join("") } fn action_for<'a>(hint: ValueHint) -> Vec<String> { match hint { // TODO actions for command are wrong Unknown => vec![], Other => vec![], AnyPath => vec!["$files"], FilePath => vec!["$files"], DirPath => vec!["$directories"], ExecutablePath => vec!["$files"], CommandName => vec!["$executables", "$files"], CommandString => vec!["$executables", "$files"], CommandWithArguments => vec!["TODO"], // TODO Username => vec!["$carapace.os.Users"], Hostname => vec!["$carapace.net.Hosts"], Url => vec![], EmailAddress => vec![], _ => vec![], } .into_iter() .map(String::from) .collect() } �����������������������������carapace_spec_clap-1.1.0/src/lib.rs�����������������������������������������������������������������0000644�0000000�0000000�00000000060�10461020230�0015272�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������mod carapace_spec; pub use carapace_spec::Spec; ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/tests/carapace_spec.rs�����������������������������������������������������0000644�0000000�0000000�00000003425�10461020230�0017660�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������mod common; #[test] fn basic() { let name = "basic"; let cmd = common::basic_command(name); common::assert_matches( snapbox::file!["snapshots/basic.yaml"], carapace_spec_clap::Spec, cmd, name, ); } #[test] fn feature_sample() { let name = "feature_sample"; let cmd = common::feature_sample_command(name); common::assert_matches( snapbox::file!["snapshots/feature_sample.yaml"], carapace_spec_clap::Spec, cmd, name, ); } #[test] fn special_commands() { let name = "special_commands"; let cmd = common::special_commands_command(name); common::assert_matches( snapbox::file!["snapshots/special_commands.yaml"], carapace_spec_clap::Spec, cmd, name, ); } #[test] fn quoting() { let name = "quoting"; let cmd = common::quoting_command(name); common::assert_matches( snapbox::file!["snapshots/quoting.yaml"], carapace_spec_clap::Spec, cmd, name, ); } #[test] fn aliases() { let name = "aliases"; let cmd = common::aliases_command(name); common::assert_matches( snapbox::file!["snapshots/aliases.yaml"], carapace_spec_clap::Spec, cmd, name, ); } #[test] fn sub_subcommands() { let name = "sub_subcommands"; let cmd = common::sub_subcommands_command(name); common::assert_matches( snapbox::file!["snapshots/sub_subcommands.yaml"], carapace_spec_clap::Spec, cmd, name, ); } #[test] fn value_hint() { let name = "value_hint"; let cmd = common::value_hint_command(name); common::assert_matches( snapbox::file!["snapshots/value_hint.yaml"], carapace_spec_clap::Spec, cmd, name, ); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/tests/common.rs������������������������������������������������������������0000644�0000000�0000000�00000021177�10461020230�0016403�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#![allow(dead_code)] // shared with other test modules use snapbox::IntoData; pub fn basic_command(name: &'static str) -> clap::Command { clap::Command::new(name) .arg( clap::Arg::new("config") .short('c') .global(true) .action(clap::ArgAction::SetTrue), ) .arg( clap::Arg::new("v") .short('v') .conflicts_with("config") .action(clap::ArgAction::SetTrue), ) .subcommand( clap::Command::new("test").about("Subcommand").arg( clap::Arg::new("debug") .short('d') .action(clap::ArgAction::Count), ), ) } pub fn feature_sample_command(name: &'static str) -> clap::Command { clap::Command::new(name) .version("3.0") .propagate_version(true) .about("Tests completions") .arg( clap::Arg::new("file") .value_hint(clap::ValueHint::FilePath) .help("some input file"), ) .arg( clap::Arg::new("config") .action(clap::ArgAction::Count) .help("some config file") .short('c') .visible_short_alias('C') .long("config") .visible_alias("conf"), ) .arg(clap::Arg::new("choice").value_parser(["first", "second"])) .subcommand( clap::Command::new("test").about("tests things").arg( clap::Arg::new("case") .long("case") .action(clap::ArgAction::Set) .help("the case to test"), ), ) } pub fn special_commands_command(name: &'static str) -> clap::Command { feature_sample_command(name) .subcommand( clap::Command::new("some_cmd") .about("tests other things") .arg( clap::Arg::new("config") .long("config") .hide(true) .action(clap::ArgAction::Set) .require_equals(true) .help("the other case to test"), ) .arg(clap::Arg::new("path").num_args(1..)), ) .subcommand(clap::Command::new("some-cmd-with-hyphens").alias("hyphen")) .subcommand(clap::Command::new("some-hidden-cmd").hide(true)) } pub fn quoting_command(name: &'static str) -> clap::Command { clap::Command::new(name) .version("3.0") .arg( clap::Arg::new("single-quotes") .long("single-quotes") .action(clap::ArgAction::SetTrue) .help("Can be 'always', 'auto', or 'never'"), ) .arg( clap::Arg::new("double-quotes") .long("double-quotes") .action(clap::ArgAction::SetTrue) .help("Can be \"always\", \"auto\", or \"never\""), ) .arg( clap::Arg::new("backticks") .long("backticks") .action(clap::ArgAction::SetTrue) .help("For more information see `echo test`"), ) .arg( clap::Arg::new("backslash") .long("backslash") .action(clap::ArgAction::SetTrue) .help("Avoid '\\n'"), ) .arg( clap::Arg::new("brackets") .long("brackets") .action(clap::ArgAction::SetTrue) .help("List packages [filter]"), ) .arg( clap::Arg::new("expansions") .long("expansions") .action(clap::ArgAction::SetTrue) .help("Execute the shell command with $SHELL"), ) .subcommands([ clap::Command::new("cmd-single-quotes").about("Can be 'always', 'auto', or 'never'"), clap::Command::new("cmd-double-quotes") .about("Can be \"always\", \"auto\", or \"never\""), clap::Command::new("cmd-backticks").about("For more information see `echo test`"), clap::Command::new("cmd-backslash").about("Avoid '\\n'"), clap::Command::new("cmd-brackets").about("List packages [filter]"), clap::Command::new("cmd-expansions").about("Execute the shell command with $SHELL"), ]) } pub fn aliases_command(name: &'static str) -> clap::Command { clap::Command::new(name) .version("3.0") .about("testing bash completions") .arg( clap::Arg::new("flag") .short('f') .visible_short_alias('F') .long("flag") .action(clap::ArgAction::SetTrue) .visible_alias("flg") .help("cmd flag"), ) .arg( clap::Arg::new("option") .short('o') .visible_short_alias('O') .long("option") .visible_alias("opt") .help("cmd option") .action(clap::ArgAction::Set), ) .arg(clap::Arg::new("positional")) } pub fn sub_subcommands_command(name: &'static str) -> clap::Command { feature_sample_command(name).subcommand( clap::Command::new("some_cmd") .about("top level subcommand") .subcommand( clap::Command::new("sub_cmd").about("sub-subcommand").arg( clap::Arg::new("config") .long("config") .action(clap::ArgAction::Set) .value_parser([clap::builder::PossibleValue::new( "Lest quotes aren't escaped.", )]) .help("the other case to test"), ), ), ) } pub fn value_hint_command(name: &'static str) -> clap::Command { clap::Command::new(name) .arg( clap::Arg::new("choice") .long("choice") .action(clap::ArgAction::Set) .value_parser(["bash", "fish", "zsh"]), ) .arg( clap::Arg::new("unknown") .long("unknown") .value_hint(clap::ValueHint::Unknown), ) .arg( clap::Arg::new("other") .long("other") .value_hint(clap::ValueHint::Other), ) .arg( clap::Arg::new("path") .long("path") .short('p') .value_hint(clap::ValueHint::AnyPath), ) .arg( clap::Arg::new("file") .long("file") .short('f') .value_hint(clap::ValueHint::FilePath), ) .arg( clap::Arg::new("dir") .long("dir") .short('d') .value_hint(clap::ValueHint::DirPath), ) .arg( clap::Arg::new("exe") .long("exe") .short('e') .value_hint(clap::ValueHint::ExecutablePath), ) .arg( clap::Arg::new("cmd_name") .long("cmd-name") .value_hint(clap::ValueHint::CommandName), ) .arg( clap::Arg::new("cmd") .long("cmd") .short('c') .value_hint(clap::ValueHint::CommandString), ) .arg( clap::Arg::new("command_with_args") .action(clap::ArgAction::Set) .num_args(1..) .trailing_var_arg(true) .value_hint(clap::ValueHint::CommandWithArguments), ) .arg( clap::Arg::new("user") .short('u') .long("user") .value_hint(clap::ValueHint::Username), ) .arg( clap::Arg::new("host") .short('H') .long("host") .value_hint(clap::ValueHint::Hostname), ) .arg( clap::Arg::new("url") .long("url") .value_hint(clap::ValueHint::Url), ) .arg( clap::Arg::new("email") .long("email") .value_hint(clap::ValueHint::EmailAddress), ) } pub(crate) fn assert_matches( expected: impl IntoData, gen: impl clap_complete::Generator, mut cmd: clap::Command, name: &'static str, ) { let mut buf = vec![]; clap_complete::generate(gen, &mut cmd, name, &mut buf); snapbox::Assert::new() .action_env(snapbox::assert::DEFAULT_ACTION_ENV) .normalize_paths(false) .eq(buf, expected); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/tests/snapshots/aliases.yaml�����������������������������������������������0000644�0000000�0000000�00000000215�10461020230�0021062�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: aliases description: testing bash completions flags: -f, --flag: cmd flag -o, --option=: cmd option -V, --version: Print version �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/tests/snapshots/basic.yaml�������������������������������������������������0000644�0000000�0000000�00000000214�10461020230�0020521�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: basic description: '' flags: -v: '' persistentflags: -c: '' commands: - name: test description: Subcommand flags: -d*: '' ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/tests/snapshots/feature_sample.yaml����������������������������������������0000644�0000000�0000000�00000000367�10461020230�0022445�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: feature_sample description: Tests completions flags: -c, --config*: some config file -V, --version: Print version commands: - name: test description: tests things flags: --case=: the case to test -V, --version: Print version �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/tests/snapshots/quoting.yaml�����������������������������������������������0000644�0000000�0000000�00000001400�10461020230�0021124�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: quoting description: '' flags: --backslash: Avoid '\n' --backticks: For more information see `echo test` --brackets: List packages [filter] --double-quotes: Can be "always", "auto", or "never" --expansions: Execute the shell command with $SHELL --single-quotes: Can be 'always', 'auto', or 'never' -V, --version: Print version commands: - name: cmd-single-quotes description: Can be 'always', 'auto', or 'never' - name: cmd-double-quotes description: Can be "always", "auto", or "never" - name: cmd-backticks description: For more information see `echo test` - name: cmd-backslash description: Avoid '\n' - name: cmd-brackets description: List packages [filter] - name: cmd-expansions description: Execute the shell command with $SHELL ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/tests/snapshots/special_commands.yaml��������������������������������������0000644�0000000�0000000�00000000706�10461020230�0022747�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: special_commands description: Tests completions flags: -c, --config*: some config file -V, --version: Print version commands: - name: test description: tests things flags: --case=: the case to test -V, --version: Print version - name: some_cmd description: tests other things flags: -V, --version: Print version - name: some-cmd-with-hyphens aliases: - hyphen description: '' flags: -V, --version: Print version ����������������������������������������������������������carapace_spec_clap-1.1.0/tests/snapshots/sub_subcommands.yaml���������������������������������������0000644�0000000�0000000�00000001075�10461020230�0022632�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: sub_subcommands description: Tests completions flags: -c, --config*: some config file -V, --version: Print version commands: - name: test description: tests things flags: --case=: the case to test -V, --version: Print version - name: some_cmd description: top level subcommand flags: -V, --version: Print version commands: - name: sub_cmd description: sub-subcommand flags: --config=: the other case to test -V, --version: Print version completion: flag: config: - Lest quotes aren't escaped. �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������carapace_spec_clap-1.1.0/tests/snapshots/value_hint.yaml��������������������������������������������0000644�0000000�0000000�00000001131�10461020230�0021575�0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: value_hint description: '' flags: --choice=: '' -c, --cmd=: '' --cmd-name=: '' -d, --dir=: '' --email=: '' -e, --exe=: '' -f, --file=: '' -H, --host=: '' --other=: '' -p, --path=: '' --unknown=: '' --url=: '' -u, --user=: '' completion: flag: choice: - bash - fish - zsh cmd: - $executables - $files cmd-name: - $executables - $files dir: - $directories exe: - $files file: - $files host: - $carapace.net.Hosts path: - $files user: - $carapace.os.Users positionalany: - TODO �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������