Skip to content

Commit

Permalink
[meta] switch to clap v3
Browse files Browse the repository at this point in the history
Also update the MSRV to Rust 1.54 since clap v3 requires that version.
  • Loading branch information
sunshowers committed Jan 11, 2022
1 parent 97c859f commit e34eee6
Show file tree
Hide file tree
Showing 21 changed files with 236 additions and 188 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
# 1.53 is the MSRV
rust-version: [ 1.53, stable ]
# 1.54 is the MSRV
rust-version: [ 1.54, stable ]
fail-fast: false
env:
RUSTFLAGS: -D warnings
Expand Down Expand Up @@ -127,8 +127,8 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
# 1.53 is the MSRV
rust-version: [ 1.53, stable ]
# 1.54 is the MSRV
rust-version: [ 1.54, stable ]
fail-fast: false
env:
RUSTFLAGS: -D warnings
Expand Down
83 changes: 70 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions cargo-guppy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ edition = "2018"
camino = "1.0.5"
# disable tracing integration since we don't use it
color-eyre = { version = "0.5.11", default-features = false }
clap = "2.33.3"
clap = { version = "3.0.6", features = ["derive"] }
dialoguer = "0.9.0"
guppy = { version = "0.12.0", path = "../guppy", features = ["summaries"] }
guppy-cmdlib = { path = "../guppy-cmdlib" }
itertools = "0.10.3"
pathdiff = { version = "0.2.1", features = ["camino"] }
serde = { version = "1.0.130", features = ["derive"] }
serde_json = "1.0.72"
structopt = "0.3.25"
toml_edit = "0.10.1"
guppy-workspace-hack = { version = "0.1", path = "../workspace-hack" }
41 changes: 19 additions & 22 deletions cargo-guppy/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//! Implementations for options shared by commands.

use clap::arg_enum;
use clap::{ArgEnum, Parser};
use color_eyre::eyre::{ensure, eyre, Result, WrapErr};
use guppy::{
graph::{DependencyDirection, DependencyReq, PackageGraph, PackageLink, PackageQuery},
Expand All @@ -12,16 +12,13 @@ use guppy::{
};
use guppy_cmdlib::string_to_platform_spec;
use std::collections::HashSet;
use structopt::StructOpt;

arg_enum! {
#[derive(Copy, Clone, Debug)]
pub enum Kind {
All,
Workspace,
DirectThirdParty,
ThirdParty,
}

#[derive(ArgEnum, Copy, Clone, Debug)]
pub enum Kind {
All,
Workspace,
DirectThirdParty,
ThirdParty,
}

impl Kind {
Expand All @@ -37,13 +34,13 @@ impl Kind {
}
}

#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct QueryOptions {
/// Query reverse transitive dependencies (default: forward)
#[structopt(long = "query-reverse", parse(from_flag = parse_direction))]
#[clap(long = "query-reverse", parse(from_flag = parse_direction))]
direction: DependencyDirection,

#[structopt(rename_all = "screaming_snake_case")]
#[clap(rename_all = "screaming_snake_case")]
/// The root packages to start the query from
roots: Vec<String>,
}
Expand All @@ -68,9 +65,9 @@ impl QueryOptions {
}
}

#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct BaseFilterOptions {
#[structopt(
#[clap(
long,
rename_all = "kebab-case",
name = "package",
Expand All @@ -80,7 +77,7 @@ pub struct BaseFilterOptions {
/// removing a dependency affects the graph
pub omit_edges_into: Vec<String>,

#[structopt(long, short, possible_values = &Kind::variants(), case_insensitive = true, default_value = "all")]
#[clap(long, short, arg_enum, default_value = "all")]
/// Kind of crates to select
pub kind: Kind,
}
Expand All @@ -96,20 +93,20 @@ impl BaseFilterOptions {
}
}

#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
pub struct FilterOptions {
#[structopt(flatten)]
#[clap(flatten)]
pub base_opts: BaseFilterOptions,

#[structopt(long, rename_all = "kebab-case")]
#[clap(long, rename_all = "kebab-case")]
/// Include dev dependencies
pub include_dev: bool,

#[structopt(long, rename_all = "kebab-case")]
#[clap(long, rename_all = "kebab-case")]
/// Include build dependencies
pub include_build: bool,

#[structopt(long)]
#[clap(long)]
/// Target to filter, "current", "any" or "always" [default: any]
pub target: Option<String>,
}
Expand Down
Loading

0 comments on commit e34eee6

Please sign in to comment.