Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jul 8, 2022
1 parent 8ab9c81 commit 01d35f3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ To check all crates with minimal version dependencies:
cargo minimal-versions check --workspace
```

**Note**: ([If cargo-minimal-versions determines that it is necessary to do so for a correct minimal versions check](#details),) cargo-minimal-versions modifies `Cargo.toml` and `Cargo.lock` while running and restores it when finished. Any changes you made to those files during running will not be preserved.
**Note:** ([If cargo-minimal-versions determines that it is necessary to do so for a correct minimal versions check](#details),) cargo-minimal-versions modifies `Cargo.toml` and `Cargo.lock` while running and restores it when finished. Any changes you made to those files during running will not be preserved.

Normally, crates with `publish = false` do not need minimal versions check. You can skip these crates by using `--ignore-private` flag.

Expand Down Expand Up @@ -78,14 +78,14 @@ See [#6](https://github.com/taiki-e/cargo-minimal-versions/issues/6) for the rem
<!-- omit in toc -->
### Prerequisites

cargo-minimal-versions requires nightly
toolchain (to run `cargo update -Z minimal-versions`) and [cargo-hack] (to run `cargo check` & `cargo build` proper):
cargo-minimal-versions requires [cargo-hack] (to run `cargo check` & `cargo build` proper):

```sh
rustup toolchain add nightly
cargo install cargo-hack
```

cargo-minimal-versions also requires nightly toolchain (to run `cargo update -Z minimal-versions`), but this will be installed automatically if it is not already installed.

<!-- omit in toc -->
### From source

Expand Down
17 changes: 14 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub(crate) struct Args {
pub(crate) manifest_path: Option<Utf8PathBuf>,
pub(crate) workspace: bool,
pub(crate) detach_path_deps: bool,
pub(crate) ignore_private: bool,
pub(crate) cargo_args: Vec<String>,
pub(crate) rest: Vec<String>,
}
Expand All @@ -39,7 +40,7 @@ pub(crate) enum Subcommand {

impl Subcommand {
fn new(s: &str) -> Self {
// https://github.com/rust-lang/cargo/blob/3bc0e6d83f7f5da0161ce445f8864b0b639776a9/src/bin/cargo/main.rs#L50-L58
// https://github.com/rust-lang/cargo/blob/0.62.0/src/bin/cargo/main.rs#L48-L56
match s {
"b" | "build" | "c" | "check" | "r" | "run" => Self::Builtin(s.to_owned()),
"t" | "test" | "bench" => Self::BuiltinDev(s.to_owned()),
Expand All @@ -66,7 +67,7 @@ impl Args {
const SUBCMD: &str = "minimal-versions";

// rustc/cargo args must be valid Unicode
// https://github.com/rust-lang/rust/blob/3bc9dd0dd293ab82945e35888ed6d7ab802761ef/compiler/rustc_driver/src/lib.rs#L1365-L1375
// https://github.com/rust-lang/rust/blob/1.61.0/compiler/rustc_driver/src/lib.rs#L1321-L1331
fn handle_args(
args: impl IntoIterator<Item = impl Into<OsString>>,
) -> impl Iterator<Item = Result<String>> {
Expand Down Expand Up @@ -100,6 +101,7 @@ impl Args {
let mut manifest_path: Option<Utf8PathBuf> = None;
let mut verbose = 0;
let mut workspace = false;
let mut ignore_private = false;
let mut detach_path_deps = false;

let mut parser = lexopt::Parser::from_args(args);
Expand All @@ -126,6 +128,7 @@ impl Args {
Long("manifest-path") => parse_opt!(manifest_path),
Short('v') | Long("verbose") => verbose += 1,
Long("workspace") | Long("all") => workspace = true,
Long("ignore-private") => ignore_private = true,
Long("detach-path-deps") => parse_flag!(detach_path_deps),

// cargo-hack flags
Expand Down Expand Up @@ -192,7 +195,15 @@ impl Args {
cargo_args.push(path.as_str().to_owned());
}

Ok(Self { subcommand, manifest_path, workspace, detach_path_deps, cargo_args, rest })
Ok(Self {
subcommand,
manifest_path,
workspace,
ignore_private,
detach_path_deps,
cargo_args,
rest,
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/restore.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Adapted from https://github.com/taiki-e/cargo-hack/blob/e44b71139c29a6c358d73d1fbd4f31c06bc0a901/src/restore.rs
// Adapted from https://github.com/taiki-e/cargo-hack/blob/v0.5.7/src/restore.rs

use std::{
mem,
Expand Down

0 comments on commit 01d35f3

Please sign in to comment.