Skip to content

Commit dca53bc

Browse files
authored
Make --no-default-features be a toggle instead of option (#473)
Fixes #471. The changes the behavior of the `--no-default-features` flag. Before it required a value to be passed: ```sh # Disable default features bevy build --no-default-features true # Do not disable default features bevy build --no-default-features false ``` Now the flag is a toggle: ```sh # Disable default features bevy build --no-default-features # Do not disable default features bevy build ``` This is a breaking change, as passing `true` or `false` is no longer recognized.
1 parent 257e3d7 commit dca53bc

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

MIGRATION.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ To actually install the new version of the CLI, please see [the docs] and [the r
88
[the releases page]: https://github.com/TheBevyFlock/bevy_cli/releases
99
[submit an issue]: https://github.com/TheBevyFlock/bevy_cli/issues
1010

11-
> **Note**
12-
>
13-
> This document is empty for now, and will be until v0.2.0 of the CLI is released with actual breaking changes. Check back later :)
11+
## v0.1.0-alpha.1 to v0.1.0-alpha.2 (Unreleased)
12+
13+
### Make `--no-default-features` a Toggle
14+
15+
The `--no-default-features` flag for `bevy build` and `bevy run` is now a toggle instead of an option. If you previously were using `--no-default-features true`, replace it with just `--no-default-features`. If you were using `--no-default-features false`, remove it.
16+
17+
```sh
18+
# v0.1.0-alpha.1
19+
bevy build --no-default-features true
20+
bevy run --no-default-features false
21+
22+
# v0.1.0-alpha.2
23+
bevy build --no-default-features
24+
bevy run
25+
```

src/build/args.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,10 @@ impl BuildArgs {
9696
.feature_args
9797
.features
9898
.extend(config.features().iter().cloned());
99-
self.cargo_args.feature_args.is_no_default_features = Some(
100-
self.cargo_args
101-
.feature_args
102-
.is_no_default_features
103-
.unwrap_or(!config.default_features()),
104-
);
99+
// An explicit `--no-default-features` takes precedence. If `--no-default-features` is not
100+
// passed, the config's default features is used instead.
101+
self.cargo_args.feature_args.is_no_default_features =
102+
self.cargo_args.feature_args.is_no_default_features || !config.default_features();
105103
self.cargo_args.common_args.rustflags = self
106104
.cargo_args
107105
.common_args

src/external_cli/cargo/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,16 @@ pub struct CargoFeatureArgs {
2525
pub is_all_features: bool,
2626

2727
/// Do not activate the `default` feature
28-
#[clap(long = "no-default-features")]
29-
pub is_no_default_features: Option<bool>,
28+
#[clap(long = "no-default-features", action = ArgAction::SetTrue, default_value_t = false)]
29+
pub is_no_default_features: bool,
3030
}
3131

3232
impl CargoFeatureArgs {
33-
pub(crate) fn is_no_default_features(&self) -> bool {
34-
self.is_no_default_features.unwrap_or(false)
35-
}
36-
3733
pub(crate) fn args_builder(&self) -> ArgBuilder {
3834
ArgBuilder::new()
3935
.add_value_list("--features", self.features.clone())
4036
.add_flag_if("--all-features", self.is_all_features)
41-
.add_flag_if("--no-default-features", self.is_no_default_features())
37+
.add_flag_if("--no-default-features", self.is_no_default_features)
4238
}
4339
}
4440

src/run/args.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ impl RunArgs {
101101
.feature_args
102102
.features
103103
.extend(config.features().iter().cloned());
104-
self.cargo_args.feature_args.is_no_default_features = Some(
105-
self.cargo_args
106-
.feature_args
107-
.is_no_default_features
108-
.unwrap_or(!config.default_features()),
109-
);
104+
// An explicit `--no-default-features` takes precedence. If `--no-default-features` is not
105+
// passed, the config's default features is used instead.
106+
self.cargo_args.feature_args.is_no_default_features =
107+
self.cargo_args.feature_args.is_no_default_features || !config.default_features();
110108
self.cargo_args.common_args.rustflags = self
111109
.cargo_args
112110
.common_args

0 commit comments

Comments
 (0)