Skip to content

Commit

Permalink
Deprecate --no-dev-dependencies. Make it the default. Introduce `--…
Browse files Browse the repository at this point in the history
…dev-dependencies` instead.
  • Loading branch information
dpc committed Jan 15, 2022
1 parent 73e1ac6 commit 1ba1e53
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions cargo-crev/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).
- `crate verify`: better column width detection
- Better broken pipe errors handling
- Fix `verify --no-dev-dependencies` being ignored
- Deprecate `--no-dev-dependencies`. Make it the default. Introduce `--dev-dependencies` instead.

## [0.22.2](https://github.com/dpc/crev/compare/cargo-crev-v0.21.4...v0.22.2) - 2022-01-11

Expand Down
27 changes: 24 additions & 3 deletions cargo-crev/src/opts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{bail, Result};
use crev_data::{Level, Version};
use std::{ffi::OsString, path::PathBuf};
use std::{ffi::OsString, io::Write, path::PathBuf};
use structopt::StructOpt;

#[derive(Debug, StructOpt, Clone, Default)]
Expand Down Expand Up @@ -59,19 +59,27 @@ pub struct CargoOpts {
#[structopt(long = "features", value_name = "FEATURES")]
/// [cargo] Space-separated list of features to activate
pub features: Option<String>,

#[structopt(long = "all-features")]
/// [cargo] Activate all available features
pub all_features: bool,

#[structopt(long = "no-default-features")]
/// [cargo] Do not activate the `default` feature
pub no_default_features: bool,

#[structopt(long = "dev-dependencies")]
/// [cargo] Skip dev dependencies.
dev_dependencies: bool,

#[structopt(long = "no-dev-dependencies")]
/// [cargo] Skip dev dependencies.
pub no_dev_dependencies: bool,
#[structopt(long = "manifest-path", value_name = "PATH", parse(from_os_str))]
no_dev_dependencies: bool,

#[structopt(long = "manifest-path", value_name = "PATH", parse(from_os_str))]
/// [cargo] Path to Cargo.toml
pub manifest_path: Option<PathBuf>,

#[structopt(short = "Z", value_name = "FLAG")]

/// [cargo] Unstable (nightly-only) flags to Cargo
Expand All @@ -83,6 +91,19 @@ pub struct CargoOpts {
pub target: Option<Option<String>>,
}

impl CargoOpts {
pub fn dev_dependencies(&self) -> Result<bool> {
if self.dev_dependencies && self.no_dev_dependencies {
bail!("`--no-dev-dependencies` and `--dev-dependencies` can't be used together");
}
if self.no_dev_dependencies {
writeln!(std::io::stderr(), "`--no-dev-dependencies` is the default, is now ignored and will be removed in the future")?;
}

Ok(self.dev_dependencies)
}
}

#[derive(Debug, StructOpt, Clone)]
pub struct IdNew {
#[structopt(long = "url")]
Expand Down
12 changes: 6 additions & 6 deletions cargo-crev/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fn our_resolve<'a, 'cfg>(
features: &[String],
all_features: bool,
no_default_features: bool,
no_dev_dependencies: bool,
dev_dependencies: bool,
) -> CargoResult<(PackageSet<'cfg>, Resolve)> {
// there is bunch of slightly different ways to do it,
// so I leave some dead code around, in case I want to
Expand All @@ -151,7 +151,7 @@ fn our_resolve<'a, 'cfg>(
Ok((
m.summary().to_owned(),
ResolveOpts {
dev_deps: !no_dev_dependencies,
dev_deps: dev_dependencies,
features: RequestedFeatures::CliFeatures(CliFeatures::from_command_line(
features,
all_features,
Expand Down Expand Up @@ -460,7 +460,7 @@ impl Repo {
&self.features_list,
self.cargo_opts.all_features,
self.cargo_opts.no_default_features,
self.cargo_opts.no_dev_dependencies,
self.cargo_opts.dev_dependencies()?,
)?;

let rustc = self.config.load_global_rustc(Some(&workspace))?;
Expand Down Expand Up @@ -539,7 +539,7 @@ impl Repo {
&self.features_list,
self.cargo_opts.all_features,
self.cargo_opts.no_default_features,
self.cargo_opts.no_dev_dependencies,
self.cargo_opts.dev_dependencies()?,
)?;
let mut source = self.load_source()?;

Expand Down Expand Up @@ -580,7 +580,7 @@ impl Repo {
&self.features_list,
self.cargo_opts.all_features,
self.cargo_opts.no_default_features,
self.cargo_opts.no_dev_dependencies,
self.cargo_opts.dev_dependencies()?,
)?;

for pkg_id in package_set.package_ids() {
Expand Down Expand Up @@ -618,7 +618,7 @@ impl Repo {
&self.features_list,
self.cargo_opts.all_features,
self.cargo_opts.no_default_features,
self.cargo_opts.no_dev_dependencies,
self.cargo_opts.dev_dependencies()?,
)
}

Expand Down

0 comments on commit 1ba1e53

Please sign in to comment.