Skip to content

Commit 100142b

Browse files
committed
Auto merge of #98213 - notriddle:notriddle/clap-3, r=Mark-Simulacrum
Bump to clap 3 This PR, along with several others, will entirely remove the Clap 2 dependency from the rust source tree. * rust-lang/rust-installer#114 * rust-lang/rls#1779 This PR includes a submodule bump for rust-installer, which includes the following PRs: * rust-lang/rust-installer#114 * rust-lang/rust-installer#113 * rust-lang/rust-installer#115
2 parents 17355a3 + 4a7b773 commit 100142b

File tree

5 files changed

+37
-77
lines changed

5 files changed

+37
-77
lines changed

Cargo.lock

+12-55
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ dependencies = [
307307
"cargo-test-macro",
308308
"cargo-test-support",
309309
"cargo-util",
310-
"clap 3.2.5",
310+
"clap",
311311
"crates-io",
312312
"crossbeam-utils",
313313
"curl",
@@ -572,22 +572,6 @@ dependencies = [
572572
"winapi",
573573
]
574574

575-
[[package]]
576-
name = "clap"
577-
version = "2.34.0"
578-
source = "registry+https://github.com/rust-lang/crates.io-index"
579-
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
580-
dependencies = [
581-
"ansi_term",
582-
"atty",
583-
"bitflags",
584-
"strsim 0.8.0",
585-
"textwrap 0.11.0",
586-
"unicode-width",
587-
"vec_map",
588-
"yaml-rust 0.3.5",
589-
]
590-
591575
[[package]]
592576
name = "clap"
593577
version = "3.2.5"
@@ -600,9 +584,9 @@ dependencies = [
600584
"clap_lex",
601585
"indexmap",
602586
"once_cell",
603-
"strsim 0.10.0",
587+
"strsim",
604588
"termcolor",
605-
"textwrap 0.15.0",
589+
"textwrap",
606590
]
607591

608592
[[package]]
@@ -611,7 +595,7 @@ version = "3.1.1"
611595
source = "registry+https://github.com/rust-lang/crates.io-index"
612596
checksum = "df6f3613c0a3cddfd78b41b10203eb322cb29b600cbdf808a7d3db95691b8e25"
613597
dependencies = [
614-
"clap 3.2.5",
598+
"clap",
615599
]
616600

617601
[[package]]
@@ -669,7 +653,7 @@ name = "clippy_dev"
669653
version = "0.0.1"
670654
dependencies = [
671655
"aho-corasick",
672-
"clap 3.2.5",
656+
"clap",
673657
"indoc",
674658
"itertools",
675659
"opener",
@@ -1242,7 +1226,7 @@ name = "expand-yaml-anchors"
12421226
version = "0.1.0"
12431227
dependencies = [
12441228
"yaml-merge-keys",
1245-
"yaml-rust 0.4.4",
1229+
"yaml-rust",
12461230
]
12471231

12481232
[[package]]
@@ -1862,7 +1846,7 @@ name = "installer"
18621846
version = "0.0.0"
18631847
dependencies = [
18641848
"anyhow",
1865-
"clap 2.34.0",
1849+
"clap",
18661850
"flate2",
18671851
"lazy_static",
18681852
"num_cpus",
@@ -2310,7 +2294,7 @@ dependencies = [
23102294
"ammonia",
23112295
"anyhow",
23122296
"chrono",
2313-
"clap 3.2.5",
2297+
"clap",
23142298
"clap_complete",
23152299
"elasticlunr-rs",
23162300
"env_logger 0.7.1",
@@ -3385,7 +3369,7 @@ dependencies = [
33853369
name = "rustbook"
33863370
version = "0.1.0"
33873371
dependencies = [
3388-
"clap 2.34.0",
3372+
"clap",
33893373
"env_logger 0.7.1",
33903374
"mdbook",
33913375
]
@@ -3473,7 +3457,7 @@ version = "1.0.0"
34733457
dependencies = [
34743458
"bstr",
34753459
"byteorder",
3476-
"clap 3.2.5",
3460+
"clap",
34773461
"crossbeam-utils",
34783462
"libc",
34793463
"libz-sys",
@@ -4662,7 +4646,7 @@ dependencies = [
46624646
"anyhow",
46634647
"bytecount",
46644648
"cargo_metadata",
4665-
"clap 3.2.5",
4649+
"clap",
46664650
"derive-new",
46674651
"diff",
46684652
"dirs",
@@ -5053,12 +5037,6 @@ dependencies = [
50535037
"vte",
50545038
]
50555039

5056-
[[package]]
5057-
name = "strsim"
5058-
version = "0.8.0"
5059-
source = "registry+https://github.com/rust-lang/crates.io-index"
5060-
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
5061-
50625040
[[package]]
50635041
name = "strsim"
50645042
version = "0.10.0"
@@ -5199,15 +5177,6 @@ dependencies = [
51995177
"term",
52005178
]
52015179

5202-
[[package]]
5203-
name = "textwrap"
5204-
version = "0.11.0"
5205-
source = "registry+https://github.com/rust-lang/crates.io-index"
5206-
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
5207-
dependencies = [
5208-
"unicode-width",
5209-
]
5210-
52115180
[[package]]
52125181
name = "textwrap"
52135182
version = "0.15.0"
@@ -5728,12 +5697,6 @@ version = "0.2.10"
57285697
source = "registry+https://github.com/rust-lang/crates.io-index"
57295698
checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c"
57305699

5731-
[[package]]
5732-
name = "vec_map"
5733-
version = "0.8.2"
5734-
source = "registry+https://github.com/rust-lang/crates.io-index"
5735-
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
5736-
57375700
[[package]]
57385701
name = "vergen"
57395702
version = "5.1.0"
@@ -5892,15 +5855,9 @@ checksum = "fd236a7dc9bb598f349fe4a8754f49181fee50284daa15cd1ba652d722280004"
58925855
dependencies = [
58935856
"lazy_static",
58945857
"thiserror",
5895-
"yaml-rust 0.4.4",
5858+
"yaml-rust",
58965859
]
58975860

5898-
[[package]]
5899-
name = "yaml-rust"
5900-
version = "0.3.5"
5901-
source = "registry+https://github.com/rust-lang/crates.io-index"
5902-
checksum = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992"
5903-
59045861
[[package]]
59055862
name = "yaml-rust"
59065863
version = "0.4.4"

src/bootstrap/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ bootstrap_tool!(
367367
Compiletest, "src/tools/compiletest", "compiletest", is_unstable_tool = true;
368368
BuildManifest, "src/tools/build-manifest", "build-manifest";
369369
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
370-
RustInstaller, "src/tools/rust-installer", "fabricate", is_external_tool = true;
370+
RustInstaller, "src/tools/rust-installer", "rust-installer", is_external_tool = true;
371371
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
372372
ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors";
373373
LintDocs, "src/tools/lint-docs", "lint-docs";

src/tools/rustbook/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = "MIT OR Apache-2.0"
55
edition = "2021"
66

77
[dependencies]
8-
clap = "2.25.0"
8+
clap = "3.1.1"
99
env_logger = "0.7.1"
1010

1111
[dependencies.mdbook]

src/tools/rustbook/src/main.rs

+22-19
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,57 @@ use clap::crate_version;
33
use std::env;
44
use std::path::{Path, PathBuf};
55

6-
use clap::{App, AppSettings, ArgMatches, SubCommand};
6+
use clap::{arg, ArgMatches, Command};
77

88
use mdbook::errors::Result as Result3;
99
use mdbook::MDBook;
1010

1111
fn main() {
12+
let crate_version = format!("v{}", crate_version!());
1213
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
13-
let d_message = "-d, --dest-dir=[dest-dir]
14-
'The output directory for your book{n}(Defaults to ./book when omitted)'";
15-
let dir_message = "[dir]
16-
'A directory for your book{n}(Defaults to Current Directory when omitted)'";
14+
let d_arg = arg!(-d --"dest-dir" <DEST_DIR>
15+
"The output directory for your book\n(Defaults to ./book when omitted)")
16+
.required(false);
17+
let dir_arg = arg!([dir]
18+
"A directory for your book\n(Defaults to Current Directory when omitted)");
1719

18-
let matches = App::new("rustbook")
20+
let matches = Command::new("rustbook")
1921
.about("Build a book with mdBook")
2022
.author("Steve Klabnik <[email protected]>")
21-
.version(&*format!("v{}", crate_version!()))
22-
.setting(AppSettings::SubcommandRequired)
23+
.version(&*crate_version)
24+
.subcommand_required(true)
25+
.arg_required_else_help(true)
2326
.subcommand(
24-
SubCommand::with_name("build")
27+
Command::new("build")
2528
.about("Build the book from the markdown files")
26-
.arg_from_usage(d_message)
27-
.arg_from_usage(dir_message),
29+
.arg(d_arg)
30+
.arg(&dir_arg),
2831
)
2932
.subcommand(
30-
SubCommand::with_name("test")
33+
Command::new("test")
3134
.about("Tests that a book's Rust code samples compile")
32-
.arg_from_usage(dir_message),
35+
.arg(dir_arg),
3336
)
3437
.get_matches();
3538

3639
// Check which subcomamnd the user ran...
3740
match matches.subcommand() {
38-
("build", Some(sub_matches)) => {
41+
Some(("build", sub_matches)) => {
3942
if let Err(e) = build(sub_matches) {
4043
handle_error(e);
4144
}
4245
}
43-
("test", Some(sub_matches)) => {
46+
Some(("test", sub_matches)) => {
4447
if let Err(e) = test(sub_matches) {
4548
handle_error(e);
4649
}
4750
}
48-
(_, _) => unreachable!(),
51+
_ => unreachable!(),
4952
};
5053
}
5154

5255
// Build command implementation
53-
pub fn build(args: &ArgMatches<'_>) -> Result3<()> {
56+
pub fn build(args: &ArgMatches) -> Result3<()> {
5457
let book_dir = get_book_dir(args);
5558
let mut book = load_book(&book_dir)?;
5659

@@ -66,13 +69,13 @@ pub fn build(args: &ArgMatches<'_>) -> Result3<()> {
6669
Ok(())
6770
}
6871

69-
fn test(args: &ArgMatches<'_>) -> Result3<()> {
72+
fn test(args: &ArgMatches) -> Result3<()> {
7073
let book_dir = get_book_dir(args);
7174
let mut book = load_book(&book_dir)?;
7275
book.test(vec![])
7376
}
7477

75-
fn get_book_dir(args: &ArgMatches<'_>) -> PathBuf {
78+
fn get_book_dir(args: &ArgMatches) -> PathBuf {
7679
if let Some(dir) = args.value_of("dir") {
7780
// Check if path is relative from current dir, or absolute...
7881
let p = Path::new(dir);

0 commit comments

Comments
 (0)