From dd974168fda753096dafd7732f0c62d9bd1bd419 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 17 Nov 2021 15:21:31 -0600 Subject: [PATCH 1/2] docs: Fix typos --- src/build/app/mod.rs | 8 ++++---- src/build/arg/mod.rs | 4 ++-- src/build/arg/possible_value.rs | 2 +- src/output/help.rs | 2 +- typos.toml | 8 ++++++++ 5 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 typos.toml diff --git a/src/build/app/mod.rs b/src/build/app/mod.rs index f38e4820..d1e8cb7b 100644 --- a/src/build/app/mod.rs +++ b/src/build/app/mod.rs @@ -821,7 +821,7 @@ impl<'help> App<'help> { /// Does awesome things\n\ /// (C) me@mail.com\n\n\ /// - /// USAGE: myapp \n\n\ + /// USAGE: myapp \n\n\ /// /// Options:\n\ /// -h, --help Display this message\n\ @@ -829,7 +829,7 @@ impl<'help> App<'help> { /// -s Do something with stuff\n\ /// -v Be verbose\n\n\ /// - /// Commmands:\n\ + /// Commands:\n\ /// help Print this message\n\ /// work Do some work") /// # ; @@ -2490,7 +2490,7 @@ impl<'help> App<'help> { // Remove generated help and version args in the subcommand // - // Don't remove if those args are futher mutated + // Don't remove if those args are further mutated if is_generated { let generated_pos = sc .args @@ -2743,7 +2743,7 @@ impl<'help> App<'help> { // Print val_name for positional arguments. e.g. x.name_no_brackets().to_string() } else { - // Print useage string for flags arguments, e.g. <--help> + // Print usage string for flags arguments, e.g. <--help> x.to_string() } }) diff --git a/src/build/arg/mod.rs b/src/build/arg/mod.rs index 813b097b..eff596da 100644 --- a/src/build/arg/mod.rs +++ b/src/build/arg/mod.rs @@ -4367,7 +4367,7 @@ impl<'help> Arg<'help> { /// assert_eq!(files, ["file1", "file2", "file3"]); /// ``` /// - /// Although `MultipleVlaues` has been specified, we cannot use the argument more than once. + /// Although `MultipleValues` has been specified, we cannot use the argument more than once. /// /// ```rust /// # use clap::{App, Arg, ErrorKind, ArgSettings}; @@ -5120,7 +5120,7 @@ where } } } else if let Some(num_vals) = arg.num_vals { - // If number_of_values is sepcified, display the value multiple times. + // If number_of_values is specified, display the value multiple times. let arg_name = format!("<{}>", arg.name); let mut it = iter::repeat(&arg_name).take(num_vals).peekable(); while let Some(arg_name) = it.next() { diff --git a/src/build/arg/possible_value.rs b/src/build/arg/possible_value.rs index 34420e0c..33aba43c 100644 --- a/src/build/arg/possible_value.rs +++ b/src/build/arg/possible_value.rs @@ -107,7 +107,7 @@ impl<'help> PossibleValue<'help> { impl<'help> PossibleValue<'help> { /// Creates a new instance of [`PossibleValue`] using a string name. The name will be used to - /// decide wether this value was provided by the user to an argument. + /// decide whether this value was provided by the user to an argument. /// /// **NOTE:** In case it is not [hidden] it will also be shown in help messages for arguments /// that use it as a [possible value] and have not hidden them through [`Arg::hide_possible_values(true)`]. diff --git a/src/output/help.rs b/src/output/help.rs index 3850d5d9..6c742393 100644 --- a/src/output/help.rs +++ b/src/output/help.rs @@ -1039,7 +1039,7 @@ mod test { #[test] fn display_width_handles_non_ascii() { - // Popular Danish tounge-twister, the name of a fruit dessert. + // Popular Danish tongue-twister, the name of a fruit dessert. let text = "rødgrød med fløde"; assert_eq!(display_width(text), 17); // Note that the string width is smaller than the string diff --git a/typos.toml b/typos.toml new file mode 100644 index 00000000..8ccd969f --- /dev/null +++ b/typos.toml @@ -0,0 +1,8 @@ +files.extend-exclude = [ + "CHANGELOG.md", + "tests", +] +[default.extend-words] +# Acronyms +als = "als" +lits = "lits" From 4e546dd2a158376eaf7b6ed246303b5b45bdb4b5 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 17 Nov 2021 15:12:40 -0600 Subject: [PATCH 2/2] chore: Align on boilerplate --- .github/FUNDING.yml | 1 - .github/ISSUE_TEMPLATE.md | 45 -------- .github/ISSUE_TEMPLATE/bug_report.yml | 28 +---- .github/ISSUE_TEMPLATE/config.yml | 3 +- .../ISSUE_TEMPLATE/documentation_issue.yml | 34 ------ .github/ISSUE_TEMPLATE/feature_request.yml | 27 ++--- .github/PULL_REQUEST_TEMPLATE.md | 5 - .github/dependabot.yml | 8 ++ .github/settings.yml | 48 +++++++++ .github/workflows/audit.yml | 21 ++++ .github/workflows/committed.yml | 14 +++ .github/workflows/pre-commit.yml | 12 +++ .github/workflows/spelling.yml | 12 +++ .gitignore | 35 +----- .pre-commit-config.yaml | 21 ++++ Cargo.toml | 101 +++++++++--------- committed.toml | 3 + 17 files changed, 204 insertions(+), 214 deletions(-) delete mode 100644 .github/FUNDING.yml delete mode 100644 .github/ISSUE_TEMPLATE.md delete mode 100644 .github/ISSUE_TEMPLATE/documentation_issue.yml delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/dependabot.yml create mode 100644 .github/settings.yml create mode 100644 .github/workflows/audit.yml create mode 100644 .github/workflows/committed.yml create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .github/workflows/spelling.yml create mode 100644 .pre-commit-config.yaml create mode 100644 committed.toml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 0e83d98c..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -open_collective: clap diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index d3f3acf5..00000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,45 +0,0 @@ - - -### Rust Version - -* Use the output of `rustc -V` - -### Affected Version of clap - -* Can be found in Cargo.lock of your project (i.e. `grep clap Cargo.lock`) - -### Expected Behavior Summary - - -### Actual Behavior Summary - - -### Steps to Reproduce the issue - - -### Sample Code or Link to Sample Code - - -### Debug output - -Compile clap with `debug` feature: - -```toml -[dependencies] -clap = { version = "*", features = ["debug"] } -``` - -The output may be very long, so feel free to link to a gist or attach a text file - -
- Debug Output -
-
-
-Paste Debug Output Here
-
-
-
-
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index b9e10ed7..1283b2ed 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,27 +1,21 @@ name: Bug report -description: An issue with clap, clap_derive or clap_generate +description: Things not quite working right labels: 'T: bug' body: - type: checkboxes attributes: - label: Please complete the following tasks options: - label: I have searched the [discussions](https://github.com/clap-rs/clap/discussions) - required: true - label: I have searched the existing issues - required: true - - type: input + - type: textarea attributes: - label: Rust Version - description: Output of `rustc -V` + label: Description validations: required: true - type: input attributes: - label: Clap Version + label: Version description: Can be found in Cargo.lock or Cargo.toml of your project (i.e. `grep clap Cargo.lock`). PLEASE DO NOT PUT "latest" HERE, use precise version. Put `master` (or other branch) if you're using the repo directly. - validations: - required: true - type: textarea attributes: label: Minimal reproducible code @@ -32,28 +26,14 @@ body: ``` validations: required: true - - type: textarea - attributes: - label: Steps to reproduce the bug with the above code - description: A command like `cargo run -- options...` or multiple commands. - validations: - required: true - type: textarea attributes: label: Actual Behaviour description: When I do like *this*, *that* is happening and I think it shouldn't. - validations: - required: true - type: textarea attributes: label: Expected Behaviour description: I think *this* should happen instead. - validations: - required: true - - type: textarea - attributes: - label: Additional Context - description: Add any other context about the problem here. - type: textarea attributes: label: Debug Output diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index c0c84bb6..c528a2ad 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,6 +1,5 @@ blank_issues_enabled: true contact_links: - name: Ask a question - about: You've come to seek help or want to discuss something related to clap + about: For support or brainstorming url: https://github.com/clap-rs/clap/discussions/new - # TODO: Question template (waiting for discussions template feature) diff --git a/.github/ISSUE_TEMPLATE/documentation_issue.yml b/.github/ISSUE_TEMPLATE/documentation_issue.yml deleted file mode 100644 index b3596c02..00000000 --- a/.github/ISSUE_TEMPLATE/documentation_issue.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Documentation issue -description: An issue with our docs, like typo, something's missing, incorrect docs, etc... -labels: 'C: docs' -body: - - type: checkboxes - attributes: - label: Please complete the following tasks - options: - - label: I have searched the [discussions](https://github.com/clap-rs/clap/discussions) - required: true - - label: I have searched the existing issues - required: true - - type: input - attributes: - label: Clap Version - description: Can be found in Cargo.lock or Cargo.toml of your project (i.e. `grep clap Cargo.lock`). PLEASE DO NOT PUT "latest" HERE, use precise version. Put `master` (or other branch) if you're using the repo directly. - validations: - required: true - - type: input - attributes: - label: Where? - description: A hyperlink, file path, some item, *something*. - validations: - required: true - - type: textarea - attributes: - label: What's wrong? - description: Explain what the issue is about, like - "The doc says that the sun is green!". - validations: - required: true - - type: textarea - attributes: - label: How to fix? - description: Any solution you think is right, like - "Everybody knows that the sun is blue!". diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 442a17f0..7e702caa 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -4,35 +4,22 @@ labels: 'T: new feature' body: - type: checkboxes attributes: - label: Please complete the following tasks options: - label: I have searched the [discussions](https://github.com/clap-rs/clap/discussions) - required: true - label: I have searched the existing issues - required: true - type: input attributes: - label: Clap Version + label: Version description: Can be found in Cargo.lock or Cargo.toml of your project (i.e. `grep clap Cargo.lock`). PLEASE DO NOT PUT "latest" HERE, use precise version. Put `master` (or other branch) if you're using the repo directly. - validations: - required: true - type: textarea attributes: - label: Describe your use case - description: Describe the problem you're trying to solve. This is not mandatory and we *do* consider features without a specific use case, but real problems have priority. - validations: - required: true + label: Use Case + description: Describe the problem you're trying to solve. - type: textarea attributes: - label: Describe the solution you'd like - description: Please explain what the wanted solution should look like. You are **strongly encouraged** to attach a snippet of (pseudo)code. - validations: - required: true + label: Requirements + description: Describe what is needed to satisfy your use case. - type: textarea attributes: - label: Alternatives, if applicable - description: A clear and concise description of any alternative solutions or features you've managed to come up with. - - type: textarea - attributes: - label: Additional Context - description: Add any other context about the feature request here. + label: Possible Solutions + description: A clear and concise description of any solutions or features you've managed to come up with. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d10555df..00000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..c6fcef4b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: cargo + directory: "/" + schedule: + interval: monthly + time: "07:00" + open-pull-requests-limit: 10 diff --git a/.github/settings.yml b/.github/settings.yml new file mode 100644 index 00000000..ff8ac15c --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,48 @@ +# These settings are synced to GitHub by https://probot.github.io/apps/settings/ + +repository: + description: A full featured, fast Command Line Argument Parser for Rust + homepage: docs.rs/clap + topics: rust cli command-line argparse clap + has_issues: true + has_projects: false + has_wiki: false + has_downloads: true + default_branch: main + + allow_squash_merge: true + allow_merge_commit: true + allow_rebase_merge: true + + # Manual: allow_auto_merge: true, see https://github.com/probot/settings/issues/402 + delete_branch_on_merge: true + +labels: + # Type + - name: bug + color: '#b60205' + description: Not as expected + - name: enhancement + color: '#1d76db' + description: Improve the expected + # Flavor + - name: question + color: "#cc317c" + description: Uncertainty is involved + - name: breaking-change + color: "#e99695" + - name: good first issue + color: '#c2e0c6' + description: Help wanted! + +branches: + - name: main + protection: + required_pull_request_reviews: null + required_conversation_resolution: true + required_status_checks: + # Required. Require branches to be up to date before merging. + strict: false + contexts: ["CI", "Lint Commits", "Spell Check with Typos"] + enforce_admins: false + restrictions: null diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 00000000..f369695a --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,21 @@ +name: Security audit +on: + pull_request: + paths: + - '**/Cargo.toml' + - '**/Cargo.lock' + push: + paths: + - '**/Cargo.toml' + - '**/Cargo.lock' + schedule: + - cron: '3 3 3 * *' +jobs: + security_audit: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/committed.yml b/.github/workflows/committed.yml new file mode 100644 index 00000000..b6433d3b --- /dev/null +++ b/.github/workflows/committed.yml @@ -0,0 +1,14 @@ +name: Lint Commits +on: [pull_request] + +jobs: + committed: + name: Lint Commits + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Lint Commits + uses: crate-ci/committed@master diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..18e33253 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,12 @@ +name: pre-commit +on: + pull_request: + push: + branches: [source] +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - uses: pre-commit/action@v2.0.3 diff --git a/.github/workflows/spelling.yml b/.github/workflows/spelling.yml new file mode 100644 index 00000000..8d296517 --- /dev/null +++ b/.github/workflows/spelling.yml @@ -0,0 +1,12 @@ +name: Spelling +on: [pull_request] + +jobs: + spelling: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v2 + - name: Spell Check Repo + uses: crate-ci/typos@master diff --git a/.gitignore b/.gitignore index 0feb4e4f..a9d37c56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1,2 @@ -# Compiled files -*.o -*.so -*.rlib -*.dll - -# Executables -*.exe - -# Generated by Cargo -target/ - -# Cargo files +target Cargo.lock - -# Temp files -.*~ - -# Backup files -*.bak -*.bk -*.orig - -# Project files -.vscode/* -.idea/* -clap-rs.iml - -# Auxiliary files -test-results.test -expanded.rs -clap_derive/expanded.rs - -# ctags -**/*.vi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..10b8b7c6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + stages: [commit] + - id: check-json + stages: [commit] + - id: check-toml + stages: [commit] + - id: check-merge-conflict + stages: [commit] + - id: check-case-conflict + stages: [commit] + - id: detect-private-key + stages: [commit] + - repo: https://github.com/crate-ci/committed + rev: v0.2.5 + hooks: + - id: committed + stages: [commit-msg] diff --git a/Cargo.toml b/Cargo.toml index 6f3956f9..88facf26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,21 +1,22 @@ +[workspace] +members = [ + "clap_derive", + "clap_generate", + "clap_generate_fig", +] + [package] name = "clap" version = "3.0.0-beta.5" -edition = "2018" +description = "A simple to use, efficient, and full-featured Command Line Argument Parser" authors = [ "Kevin K. ", "Clap Maintainers" ] -include = [ - "src/**/*", - "Cargo.toml", - "LICENSE-*", - "README.md" -] -description = "A simple to use, efficient, and full-featured Command Line Argument Parser" repository = "https://github.com/clap-rs/clap" documentation = "https://docs.rs/clap/" homepage = "https://clap.rs/" +categories = ["command-line-interface"] keywords = [ "argument", "cli", @@ -23,9 +24,51 @@ keywords = [ "parser", "parse" ] -categories = ["command-line-interface"] +edition = "2018" license = "MIT OR Apache-2.0" readme = "README.md" +include = [ + "build.rs", + "src/**/*", + "Cargo.toml", + "LICENSE*", + "README.md", + "benches/**/*", + "examples/**/*" +] + +[package.metadata.docs.rs] +features = ["yaml", "regex", "unstable-replace", "unstable-multicall", "unstable-grouped"] + +[features] +default = [ + "std", + "derive", + "cargo", + "color", + "env", + "suggestions", + "unicode", +] +debug = ["clap_derive/debug", "backtrace"] # Enables debug messages + +# Used in default +std = ["indexmap/std"] # support for no_std in a backwards-compatible way +derive = ["clap_derive", "lazy_static"] +cargo = ["lazy_static"] # Disable if you're not using Cargo, enables Cargo-env-var-dependent macros +color = ["atty", "termcolor"] +env = [] # Use environment variables during arg parsing +suggestions = ["strsim"] +unicode = ["textwrap/unicode-width", "unicase"] # Support for unicode characters in arguments and help messages + +# Optional +wrap_help = ["terminal_size", "textwrap/terminal_size"] +yaml = ["yaml-rust"] + +# In-work features +unstable-replace = [] +unstable-multicall = [] +unstable-grouped = [] [lib] bench = false @@ -90,36 +133,6 @@ path = "examples/24a_multicall_busybox.rs" name = "hostname" path = "examples/24b_multicall_hostname.rs" -[features] -default = [ - "std", - "derive", - "cargo", - "color", - "env", - "suggestions", - "unicode", -] -debug = ["clap_derive/debug", "backtrace"] # Enables debug messages - -# Used in default -std = ["indexmap/std"] # support for no_std in a backwards-compatible way -derive = ["clap_derive", "lazy_static"] -cargo = ["lazy_static"] # Disable if you're not using Cargo, enables Cargo-env-var-dependent macros -color = ["atty", "termcolor"] -env = [] # Use environment variables during arg parsing -suggestions = ["strsim"] -unicode = ["textwrap/unicode-width", "unicase"] # Support for unicode characters in arguments and help messages - -# Optional -wrap_help = ["terminal_size", "textwrap/terminal_size"] -yaml = ["yaml-rust"] - -# In-work features -unstable-replace = [] -unstable-multicall = [] -unstable-grouped = [] - [profile.test] opt-level = 1 @@ -127,13 +140,3 @@ opt-level = 1 lto = true codegen-units = 1 -[package.metadata.docs.rs] -features = ["yaml", "regex", "unstable-replace", "unstable-multicall", "unstable-grouped"] -targets = ["x86_64-unknown-linux-gnu"] - -[workspace] -members = [ - "clap_derive", - "clap_generate", - "clap_generate_fig", -] diff --git a/committed.toml b/committed.toml new file mode 100644 index 00000000..08815cf9 --- /dev/null +++ b/committed.toml @@ -0,0 +1,3 @@ +style="conventional" +ignore_author_re="dependabot" +merge_commit = false