119625d8cSopenharmony_ci# How to Contribute 219625d8cSopenharmony_ci 319625d8cSopenharmony_ciContributions are always welcome! And there is a multitude of ways in which you can help depending on what you like to do, or are good at. Anything from documentation, code cleanup, issue completion, new features, you name it, even filing issues is contributing and greatly appreciated! 419625d8cSopenharmony_ci 519625d8cSopenharmony_ci## Goals 619625d8cSopenharmony_ci 719625d8cSopenharmony_ciThere are a few goals of `clap` that I'd like to maintain throughout contributions. If your proposed changes break, or go against any of these goals we'll discuss the changes further before merging (but will *not* be ignored, all contributes are welcome!). These are by no means hard-and-fast rules, as I'm no expert and break them myself from time to time (even if by mistake or ignorance :P). 819625d8cSopenharmony_ci 919625d8cSopenharmony_ci* Remain backwards compatible when possible 1019625d8cSopenharmony_ci - If backwards compatibility *must* be broken, use deprecation warnings if at all possible before removing legacy code 1119625d8cSopenharmony_ci - This does not apply for security concerns 1219625d8cSopenharmony_ci* Parse arguments quickly 1319625d8cSopenharmony_ci - Parsing of arguments shouldn't slow down usage of the main program 1419625d8cSopenharmony_ci - This is also true of generating help and usage information (although *slightly* less stringent, as the program is about to exit) 1519625d8cSopenharmony_ci* Try to be cognizant of memory usage 1619625d8cSopenharmony_ci - Once parsing is complete, the memory footprint of `clap` should be low since the main program is the star of the show 1719625d8cSopenharmony_ci* `panic!` on *developer* error 1819625d8cSopenharmony_ci (e.g. [apps](https://github.com/clap-rs/clap/blob/62eff1f8d3394cef819b4aa7b23a1032fc584f03/src/build/app/debug_asserts.rs) and [args](https://github.com/clap-rs/clap/blob/62eff1f8d3394cef819b4aa7b23a1032fc584f03/src/build/arg/debug_asserts.rs)), 1919625d8cSopenharmony_ci exit gracefully on *end-user* error 2019625d8cSopenharmony_ci 2119625d8cSopenharmony_ci## General Overview 2219625d8cSopenharmony_ci 2319625d8cSopenharmony_ci### Where to Start 2419625d8cSopenharmony_ci 2519625d8cSopenharmony_ci- [Discussions](https://github.com/clap-rs/clap/discussions) can be useful for getting help and brainstorming 2619625d8cSopenharmony_ci- [Issues](https://github.com/clap-rs/clap/issues) work well discussing a need and how to solve it 2719625d8cSopenharmony_ci - Focus: requirements gathering and design discussions 2819625d8cSopenharmony_ci - Sometimes a branch or Draft PR might be used to demonstrate an idea 2919625d8cSopenharmony_ci- [PRs](https://github.com/clap-rs/clap/pulls) work well for when the solution has already been discussed as an Issue or there is little to no discussion (obvious bug or documentation fixes) 3019625d8cSopenharmony_ci - Focus: implementation discussions 3119625d8cSopenharmony_ci 3219625d8cSopenharmony_ci### Compatibility Expectations 3319625d8cSopenharmony_ci 3419625d8cSopenharmony_ciOur releases fall into one of: 3519625d8cSopenharmony_ci- Major releases which are reserved for breaking changes 3619625d8cSopenharmony_ci - Aspire to at least 6-9 months between releases 3719625d8cSopenharmony_ci - Remove all deprecated functionality 3819625d8cSopenharmony_ci - Changes in help/error output that could cause glaring inconsistencies in end-user applications 3919625d8cSopenharmony_ci - Try to minimize new breaking changes to ease user transition and reduce time "we go dark" (unreleased feature-branch) 4019625d8cSopenharmony_ci - Upon release, a minor release will be made for the previous major that enables `deprecated` feature by default 4119625d8cSopenharmony_ci- Minor releases which are for minor compatibility changes 4219625d8cSopenharmony_ci - Aspire to at least 2 months between releases 4319625d8cSopenharmony_ci - Changes to MSRV 4419625d8cSopenharmony_ci - Wide-spread help/error output changes that would cause minor inconsistencies in end-user applications 4519625d8cSopenharmony_ci - Deprecating existing functionality (behind the `deprecated` feature flag) 4619625d8cSopenharmony_ci - Making the `deprecated` feature flag enabled-by-default (only on last planned minor release) 4719625d8cSopenharmony_ci - `#[doc(hidden)]` all deprecated items in the prior minor release 4819625d8cSopenharmony_ci- Patch releases 4919625d8cSopenharmony_ci - One for every user-facing, user-contributed PR (i.e. release early, release often) 5019625d8cSopenharmony_ci - Changes in help/error output that are one-off or improving consistency so as to not increase inconsistency with end-user applications 5119625d8cSopenharmony_ci 5219625d8cSopenharmony_ciIf your change does not fit within a "patch" release, please coordinate with the clap maintainers for how to handle the situation. 5319625d8cSopenharmony_ci 5419625d8cSopenharmony_ciSome practices to avoid breaking changes 5519625d8cSopenharmony_ci- Duplicate functionality, with old functionality marked as "deprecated" 5619625d8cSopenharmony_ci - Common documentation pattern: `/// Deprecated in [Issue #XXX](https://github.com/clap-rs/clap/issues/XXX), replaced with [intra-doc-link]` 5719625d8cSopenharmony_ci - Common deprecation pattern: `#[cfg_attr(feature = "deprecated", deprecated(since = "X.Y.Z", note = "Replaced with `ITEM` in Issue #XXX"))]` 5819625d8cSopenharmony_ci - `deprecated` feature flag is to allow people to process them on their 5919625d8cSopenharmony_ci time table and allow us to process feedback from early adopters before 6019625d8cSopenharmony_ci requiring everyone to process them on the next major version. 6119625d8cSopenharmony_ci - Please keep API addition and deprecation in separate commits in a PR to make it easier to review 6219625d8cSopenharmony_ci- Develop the feature behind an `unstable-<name>` feature flag with a stablization tracking issue (e.g. [Multicall Tracking issue](https://github.com/clap-rs/clap/issues/2861)) 6319625d8cSopenharmony_ci 6419625d8cSopenharmony_ci### Version Support Policy 6519625d8cSopenharmony_ci 6619625d8cSopenharmony_ciAs we work towards [a more flexible architecture](https://github.com/clap-rs/clap/discussions/3476), we hope to support multiple major versions to help ease users through the upgrade churn. 6719625d8cSopenharmony_ci 6819625d8cSopenharmony_ci| Version | Status | Support | End-of-Life | 6919625d8cSopenharmony_ci|------------------------------------------------------|---------------|---------|-------------| 7019625d8cSopenharmony_ci| [v4](https://github.com/clap-rs/clap/tree/master) | active | Features and bug fixes target `master` by default | TBD | 7119625d8cSopenharmony_ci| [v3](https://github.com/clap-rs/clap/tree/v3-master) | maintenance | Accepting trivial cherry-picks from `master` (i.e. minimal conflict resolution) by contributors and fixes for ecosystem-wide showstoppers | TBD | 7219625d8cSopenharmony_ci| [v2](https://github.com/clap-rs/clap/tree/v2-master) | deprecated | Only accepting fixes for ecosystem-wide showstoppers | TBD | 7319625d8cSopenharmony_ci| v1 | unsupported | \- | \- | 7419625d8cSopenharmony_ci 7519625d8cSopenharmony_ciNote: We have not yet determined the End-of-Life schedule for previous major versions. We will give at least a 2 month warning before changing the support status. 7619625d8cSopenharmony_ci 7719625d8cSopenharmony_ci### Verifying Changes 7819625d8cSopenharmony_ci 7919625d8cSopenharmony_ciA common (sub)set of commands for verifying your change: 8019625d8cSopenharmony_ci```sh 8119625d8cSopenharmony_ci$ make test-full 8219625d8cSopenharmony_ci$ make clippy-full 8319625d8cSopenharmony_ci$ make doc 8419625d8cSopenharmony_ci``` 8519625d8cSopenharmony_ci*(If `make` is not available on your system, you can look up what these expand to in the [Makefile](./Makefile))* 8619625d8cSopenharmony_ci 8719625d8cSopenharmony_ciCheck out the [Makefile](./Makefile) for more commands run by CI. 8819625d8cSopenharmony_ci 8919625d8cSopenharmony_ci### Debugging Clap 9019625d8cSopenharmony_ci 9119625d8cSopenharmony_ciA helpful technique is to see the `clap` debug output while developing features. In order to see the debug output while running the full test suite or individual tests, run: 9219625d8cSopenharmony_ci 9319625d8cSopenharmony_ci```console 9419625d8cSopenharmony_ci$ cargo test --features debug 9519625d8cSopenharmony_ci 9619625d8cSopenharmony_ci# Or for individual tests 9719625d8cSopenharmony_ci$ cargo test --test <test_name> --features debug 9819625d8cSopenharmony_ci``` 9919625d8cSopenharmony_ci 10019625d8cSopenharmony_ci### Preparing the PR 10119625d8cSopenharmony_ci 10219625d8cSopenharmony_ci1. `git rebase` into concise commits and remove `--fixup`s or `wip` commits (`git rebase -i HEAD~NUM` where `NUM` is number of commits back to start the rebase) 10319625d8cSopenharmony_ci2. Push your changes back to your fork (`git push origin $your-branch`) 10419625d8cSopenharmony_ci3. Create a pull request against `master`! (You can also create the pull request first, and we'll merge when ready. This a good way to discuss proposed changes.) 10519625d8cSopenharmony_ci 10619625d8cSopenharmony_ciPR expectations: 10719625d8cSopenharmony_ci- Changes are tested and, if needed, documented 10819625d8cSopenharmony_ci- PRs remain small and focused 10919625d8cSopenharmony_ci - If needed, we can put changes behind feature flags as they evolve 11019625d8cSopenharmony_ci- Commits are atomic (i.e. do a single thing) 11119625d8cSopenharmony_ci- Commits are in [Conventional Commit](https://www.conventionalcommits.org/) style 11219625d8cSopenharmony_ci 11319625d8cSopenharmony_ciWe recognize that these are ideals and we don't want lack of comfort with git 11419625d8cSopenharmony_cito get in the way of contributing. If you didn't do these, bring it up with 11519625d8cSopenharmony_cithe maintainers and we can help work around this. 11619625d8cSopenharmony_ci 11719625d8cSopenharmony_ci## Conditions for fulfilling a bounty: 11819625d8cSopenharmony_ci 11919625d8cSopenharmony_ci1. You should make a pull request which fixes the issue the bounty was promised for 12019625d8cSopenharmony_ci2. The pull request should be merged by one of the maintainers 12119625d8cSopenharmony_ci 12219625d8cSopenharmony_ci### Below are the steps to redeem a bounty: 12319625d8cSopenharmony_ci 12419625d8cSopenharmony_ci1. Go to https://opencollective.com/clap/expenses/new. 12519625d8cSopenharmony_ci2. Select **Invoice**. 12619625d8cSopenharmony_ci3. Enter **Expense Title** as "Issue Bounty". 12719625d8cSopenharmony_ci4. In **Description**, link the issue you are redeeming _(Ex: `https://github.com/clap-rs/clap/issues/1464`)_ 12819625d8cSopenharmony_ci5. In **Amount**, write the amount that the issue promised _(Ex: 10)_ 12919625d8cSopenharmony_ci6. Fill payment information and submit 13019625d8cSopenharmony_ci7. Wait for us to approve it 13119625d8cSopenharmony_ci 13219625d8cSopenharmony_ci### Can I forgo the bounty? 13319625d8cSopenharmony_ci 13419625d8cSopenharmony_ciYes, you can. In that case, you don't have to do anything except writing a 13519625d8cSopenharmony_cicomment on the issue saying that I do. The bounty will be reassigned to another 13619625d8cSopenharmony_ciissue. 13719625d8cSopenharmony_ci 13819625d8cSopenharmony_ci## Specific Tasks 13919625d8cSopenharmony_ci 14019625d8cSopenharmony_ci### Section-specific CONTRIBUTING 14119625d8cSopenharmony_ci 14219625d8cSopenharmony_ci- [Example CONTRIBUTING](./examples/README.md#contributing) 14319625d8cSopenharmony_ci- [Tutorial (builder) CONTRIBUTING](./examples/tutorial_builder/README.md#contributing) 14419625d8cSopenharmony_ci- [Tutorial (derive) CONTRIBUTING](./examples/tutorial_derive/README.md#contributing) 14519625d8cSopenharmony_ci- [clap_derive CONTRIBUTING](./clap_derive/CONTRIBUTING.md) 14619625d8cSopenharmony_ci 14719625d8cSopenharmony_ci### Updating MSRV 14819625d8cSopenharmony_ci 14919625d8cSopenharmony_ciSearch for `MSRV`, for example 15019625d8cSopenharmony_ci```bash 15119625d8cSopenharmony_ci$ rg --hidden MSRV 15219625d8cSopenharmony_ci``` 15319625d8cSopenharmony_ciAnd update all of the references 154