Skip to content

Commit 55a47f6

Browse files
Merge pull request #2863 from tertsdiepraam/clap-3
Clap 3
2 parents d64b32d + 4b79419 commit 55a47f6

221 files changed

Lines changed: 2091 additions & 2042 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Cargo.lock‎

Lines changed: 173 additions & 119 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ test = [ "uu_test" ]
244244
[workspace]
245245

246246
[dependencies]
247-
clap = { version = "2.33", features = ["wrap_help"] }
247+
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
248+
clap_complete = "3.0"
248249
lazy_static = { version="1.3" }
249250
textwrap = { version="0.14", features=["terminal_size"] }
250251
uucore = { version=">=0.0.11", package="uucore", path="src/uucore" }

‎build.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn main() {
4343
let mut tf = File::create(Path::new(&out_dir).join("test_modules.rs")).unwrap();
4444

4545
mf.write_all(
46-
"type UtilityMap<T> = HashMap<&'static str, (fn(T) -> i32, fn() -> App<'static, 'static>)>;\n\
46+
"type UtilityMap<T> = HashMap<&'static str, (fn(T) -> i32, fn() -> App<'static>)>;\n\
4747
\n\
4848
fn util_map<T: uucore::Args>() -> UtilityMap<T> {\n\
4949
\t#[allow(unused_mut)]\n\

‎src/bin/coreutils.rs‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
// For the full copyright and license information, please view the LICENSE
66
// file that was distributed with this source code.
77

8-
use clap::App;
9-
use clap::Arg;
10-
use clap::Shell;
8+
use clap::{App, Arg};
9+
use clap_complete::Shell;
1110
use std::cmp;
1211
use std::collections::hash_map::HashMap;
1312
use std::ffi::OsStr;
@@ -143,13 +142,13 @@ fn gen_completions<T: uucore::Args>(
143142
let matches = App::new("completion")
144143
.about("Prints completions to stdout")
145144
.arg(
146-
Arg::with_name("utility")
147-
.possible_values(&all_utilities)
145+
Arg::new("utility")
146+
.possible_values(all_utilities)
148147
.required(true),
149148
)
150149
.arg(
151-
Arg::with_name("shell")
152-
.possible_values(&Shell::variants())
150+
Arg::new("shell")
151+
.possible_values(Shell::possible_values())
153152
.required(true),
154153
)
155154
.get_matches_from(std::iter::once(OsString::from("completion")).chain(args));
@@ -165,12 +164,12 @@ fn gen_completions<T: uucore::Args>(
165164
let shell: Shell = shell.parse().unwrap();
166165
let bin_name = std::env::var("PROG_PREFIX").unwrap_or_default() + utility;
167166

168-
app.gen_completions_to(bin_name, shell, &mut io::stdout());
167+
clap_complete::generate(shell, &mut app, bin_name, &mut io::stdout());
169168
io::stdout().flush().unwrap();
170169
process::exit(0);
171170
}
172171

173-
fn gen_coreutils_app<T: uucore::Args>(util_map: UtilityMap<T>) -> App<'static, 'static> {
172+
fn gen_coreutils_app<T: uucore::Args>(util_map: UtilityMap<T>) -> App<'static> {
174173
let mut app = App::new("coreutils");
175174
for (_, (_, sub_app)) in util_map {
176175
app = app.subcommand(sub_app());

‎src/uu/arch/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ path = "src/arch.rs"
1616

1717
[dependencies]
1818
platform-info = "0.2"
19-
clap = { version = "2.33", features = ["wrap_help"] }
19+
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
2020
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
2121
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
2222

‎src/uu/arch/src/arch.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
2323
Ok(())
2424
}
2525

26-
pub fn uu_app() -> App<'static, 'static> {
26+
pub fn uu_app<'a>() -> App<'a> {
2727
App::new(uucore::util_name())
2828
.version(crate_version!())
2929
.about(ABOUT)

‎src/uu/base32/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ edition = "2018"
1515
path = "src/base32.rs"
1616

1717
[dependencies]
18-
clap = { version = "2.33", features = ["wrap_help"] }
18+
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
1919
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] }
2020
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
2121

‎src/uu/base32/src/base32.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
4747
)
4848
}
4949

50-
pub fn uu_app() -> App<'static, 'static> {
50+
pub fn uu_app<'a>() -> App<'a> {
5151
base_common::base_app(ABOUT)
5252
}

‎src/uu/base32/src/base_common.rs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,33 +86,33 @@ impl Config {
8686
}
8787

8888
pub fn parse_base_cmd_args(args: impl uucore::Args, about: &str, usage: &str) -> UResult<Config> {
89-
let app = base_app(about).usage(usage);
89+
let app = base_app(about).override_usage(usage);
9090
let arg_list = args
9191
.collect_str(InvalidEncodingHandling::ConvertLossy)
9292
.accept_any();
9393
Config::from(&app.get_matches_from(arg_list))
9494
}
9595

96-
pub fn base_app<'a>(about: &'a str) -> App<'static, 'a> {
96+
pub fn base_app(about: &str) -> App {
9797
App::new(uucore::util_name())
9898
.version(crate_version!())
9999
.about(about)
100100
// Format arguments.
101101
.arg(
102-
Arg::with_name(options::DECODE)
103-
.short("d")
102+
Arg::new(options::DECODE)
103+
.short('d')
104104
.long(options::DECODE)
105105
.help("decode data"),
106106
)
107107
.arg(
108-
Arg::with_name(options::IGNORE_GARBAGE)
109-
.short("i")
108+
Arg::new(options::IGNORE_GARBAGE)
109+
.short('i')
110110
.long(options::IGNORE_GARBAGE)
111111
.help("when decoding, ignore non-alphabetic characters"),
112112
)
113113
.arg(
114-
Arg::with_name(options::WRAP)
115-
.short("w")
114+
Arg::new(options::WRAP)
115+
.short('w')
116116
.long(options::WRAP)
117117
.takes_value(true)
118118
.help(
@@ -121,7 +121,7 @@ pub fn base_app<'a>(about: &'a str) -> App<'static, 'a> {
121121
)
122122
// "multiple" arguments are used to check whether there is more than one
123123
// file passed in.
124-
.arg(Arg::with_name(options::FILE).index(1).multiple(true))
124+
.arg(Arg::new(options::FILE).index(1).multiple_occurrences(true))
125125
}
126126

127127
pub fn get_input<'a>(config: &Config, stdin_ref: &'a Stdin) -> UResult<Box<dyn Read + 'a>> {

‎src/uu/base64/Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ edition = "2018"
1515
path = "src/base64.rs"
1616

1717
[dependencies]
18-
clap = { version = "2.33", features = ["wrap_help"] }
1918
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] }
2019
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
2120
uu_base32 = { version=">=0.0.8", package="uu_base32", path="../base32"}

0 commit comments

Comments
 (0)