Skip to content

Commit

Permalink
Merge pull request #27 from epage/features
Browse files Browse the repository at this point in the history
fix!: Lighten clap's default feature set
  • Loading branch information
epage authored Nov 24, 2021
2 parents afa7346 + c0f0713 commit e6fca54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
12 changes: 4 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,24 @@ features = ["doc"]
[features]
default = [
"std",
"derive",
"cargo",
"color",
"env",
"suggestions",
"unicode",
]
debug = ["clap_derive/debug", "backtrace"] # Enables debug messages
doc = ["yaml", "regex", "unstable-replace", "unstable-multicall", "unstable-grouped"] # for docs.rs

# 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
derive = ["clap_derive", "lazy_static"]
cargo = ["lazy_static"] # Disable if you're not using Cargo, enables Cargo-env-var-dependent macros
wrap_help = ["terminal_size", "textwrap/terminal_size"]
yaml = ["yaml-rust"]
env = [] # Use environment variables during arg parsing
unicode = ["textwrap/unicode-width", "unicase"] # Support for unicode characters in arguments and help messages

# In-work features
unstable-replace = []
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,8 @@ Disabling optional features can decrease the binary size of `clap` and decrease
#### Features enabled by default

* **std**: _Not Currently Used._ Placeholder for supporting `no_std` environments in a backwards compatible manner.
* **derive**: Enables the custom derive (i.e. `#[derive(Parser)]`). Without this you must use one of the other methods of creating a `clap` CLI listed above. (builds dependency `clap_derive`)
* **cargo**: Turns on macros that read values from `CARGO_*` environment variables.
* **color**: Turns on colored error messages. (builds dependency `atty`, `termcolor`)
* **env**: Turns on the usage of environment variables during parsing.
* **suggestions**: Turns on the `Did you mean '--myoption'?` feature for when users make typos. (builds dependency `strsim`)
* **unicode**: Turns on support for unicode characters in arguments and help messages. (builds dependency `textwrap`, `unicase`)

To disable these, add this to your `Cargo.toml`:

Expand All @@ -395,14 +391,17 @@ version = "3.0.0-beta.5"
default-features = false

# Cherry-pick the features you'd like to use
features = ["std", "suggestions", "color"]
features = ["std", "suggestions"]
```

#### Opt-in features

* **derive**: Enables the custom derive (i.e. `#[derive(Parser)]`). Without this you must use one of the other methods of creating a `clap` CLI listed above. (builds dependency `clap_derive`)
* **cargo**: Turns on macros that read values from `CARGO_*` environment variables.
* **env**: Turns on the usage of environment variables during parsing.
* **regex**: Enables regex validators. (builds dependency `regex`)
* **unicode**: Turns on support for unicode characters (including emoji) in arguments and help messages. (builds dependency `textwrap`, `unicase`)
* **wrap_help**: Turns on the help text wrapping feature, based on the terminal size. (builds dependency `term-size`)
* **yaml**: Enables building CLIs from YAML documents. (builds dependency `yaml-rust`)

#### Experimental features

Expand Down

0 comments on commit e6fca54

Please sign in to comment.