1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge branch 'main' into hbina-tr-reimplement-expansion

This commit is contained in:
Terts Diepraam 2022-01-21 14:42:30 +01:00
commit 9ddd61ab6b
226 changed files with 2603 additions and 2408 deletions

507
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@
[package]
name = "coreutils"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "coreutils ~ GNU coreutils (updated); implemented as universal (cross-platform) utils, written in Rust"
@ -244,113 +244,114 @@ test = [ "uu_test" ]
[workspace]
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
clap_complete = "3.0"
lazy_static = { version="1.3" }
textwrap = { version="0.14", features=["terminal_size"] }
uucore = { version=">=0.0.11", package="uucore", path="src/uucore" }
selinux = { version="0.2.3", optional = true }
# * uutils
uu_test = { optional=true, version="0.0.9", package="uu_test", path="src/uu/test" }
uu_test = { optional=true, version="0.0.12", package="uu_test", path="src/uu/test" }
#
arch = { optional=true, version="0.0.9", package="uu_arch", path="src/uu/arch" }
base32 = { optional=true, version="0.0.9", package="uu_base32", path="src/uu/base32" }
base64 = { optional=true, version="0.0.9", package="uu_base64", path="src/uu/base64" }
basename = { optional=true, version="0.0.9", package="uu_basename", path="src/uu/basename" }
basenc = { optional=true, version="0.0.9", package="uu_basenc", path="src/uu/basenc" }
cat = { optional=true, version="0.0.9", package="uu_cat", path="src/uu/cat" }
chcon = { optional=true, version="0.0.9", package="uu_chcon", path="src/uu/chcon" }
chgrp = { optional=true, version="0.0.9", package="uu_chgrp", path="src/uu/chgrp" }
chmod = { optional=true, version="0.0.9", package="uu_chmod", path="src/uu/chmod" }
chown = { optional=true, version="0.0.9", package="uu_chown", path="src/uu/chown" }
chroot = { optional=true, version="0.0.9", package="uu_chroot", path="src/uu/chroot" }
cksum = { optional=true, version="0.0.9", package="uu_cksum", path="src/uu/cksum" }
comm = { optional=true, version="0.0.9", package="uu_comm", path="src/uu/comm" }
cp = { optional=true, version="0.0.9", package="uu_cp", path="src/uu/cp" }
csplit = { optional=true, version="0.0.9", package="uu_csplit", path="src/uu/csplit" }
cut = { optional=true, version="0.0.9", package="uu_cut", path="src/uu/cut" }
date = { optional=true, version="0.0.9", package="uu_date", path="src/uu/date" }
dd = { optional=true, version="0.0.9", package="uu_dd", path="src/uu/dd" }
df = { optional=true, version="0.0.9", package="uu_df", path="src/uu/df" }
dircolors= { optional=true, version="0.0.9", package="uu_dircolors", path="src/uu/dircolors" }
dirname = { optional=true, version="0.0.9", package="uu_dirname", path="src/uu/dirname" }
du = { optional=true, version="0.0.9", package="uu_du", path="src/uu/du" }
echo = { optional=true, version="0.0.9", package="uu_echo", path="src/uu/echo" }
env = { optional=true, version="0.0.9", package="uu_env", path="src/uu/env" }
expand = { optional=true, version="0.0.9", package="uu_expand", path="src/uu/expand" }
expr = { optional=true, version="0.0.9", package="uu_expr", path="src/uu/expr" }
factor = { optional=true, version="0.0.9", package="uu_factor", path="src/uu/factor" }
false = { optional=true, version="0.0.9", package="uu_false", path="src/uu/false" }
fmt = { optional=true, version="0.0.9", package="uu_fmt", path="src/uu/fmt" }
fold = { optional=true, version="0.0.9", package="uu_fold", path="src/uu/fold" }
groups = { optional=true, version="0.0.9", package="uu_groups", path="src/uu/groups" }
hashsum = { optional=true, version="0.0.9", package="uu_hashsum", path="src/uu/hashsum" }
head = { optional=true, version="0.0.9", package="uu_head", path="src/uu/head" }
hostid = { optional=true, version="0.0.9", package="uu_hostid", path="src/uu/hostid" }
hostname = { optional=true, version="0.0.9", package="uu_hostname", path="src/uu/hostname" }
id = { optional=true, version="0.0.9", package="uu_id", path="src/uu/id" }
install = { optional=true, version="0.0.9", package="uu_install", path="src/uu/install" }
join = { optional=true, version="0.0.9", package="uu_join", path="src/uu/join" }
kill = { optional=true, version="0.0.9", package="uu_kill", path="src/uu/kill" }
link = { optional=true, version="0.0.9", package="uu_link", path="src/uu/link" }
ln = { optional=true, version="0.0.9", package="uu_ln", path="src/uu/ln" }
ls = { optional=true, version="0.0.9", package="uu_ls", path="src/uu/ls" }
logname = { optional=true, version="0.0.9", package="uu_logname", path="src/uu/logname" }
mkdir = { optional=true, version="0.0.9", package="uu_mkdir", path="src/uu/mkdir" }
mkfifo = { optional=true, version="0.0.9", package="uu_mkfifo", path="src/uu/mkfifo" }
mknod = { optional=true, version="0.0.9", package="uu_mknod", path="src/uu/mknod" }
mktemp = { optional=true, version="0.0.9", package="uu_mktemp", path="src/uu/mktemp" }
more = { optional=true, version="0.0.9", package="uu_more", path="src/uu/more" }
mv = { optional=true, version="0.0.9", package="uu_mv", path="src/uu/mv" }
nice = { optional=true, version="0.0.9", package="uu_nice", path="src/uu/nice" }
nl = { optional=true, version="0.0.9", package="uu_nl", path="src/uu/nl" }
nohup = { optional=true, version="0.0.9", package="uu_nohup", path="src/uu/nohup" }
nproc = { optional=true, version="0.0.9", package="uu_nproc", path="src/uu/nproc" }
numfmt = { optional=true, version="0.0.9", package="uu_numfmt", path="src/uu/numfmt" }
od = { optional=true, version="0.0.9", package="uu_od", path="src/uu/od" }
paste = { optional=true, version="0.0.9", package="uu_paste", path="src/uu/paste" }
pathchk = { optional=true, version="0.0.9", package="uu_pathchk", path="src/uu/pathchk" }
pinky = { optional=true, version="0.0.9", package="uu_pinky", path="src/uu/pinky" }
pr = { optional=true, version="0.0.9", package="uu_pr", path="src/uu/pr" }
printenv = { optional=true, version="0.0.9", package="uu_printenv", path="src/uu/printenv" }
printf = { optional=true, version="0.0.9", package="uu_printf", path="src/uu/printf" }
ptx = { optional=true, version="0.0.9", package="uu_ptx", path="src/uu/ptx" }
pwd = { optional=true, version="0.0.9", package="uu_pwd", path="src/uu/pwd" }
readlink = { optional=true, version="0.0.9", package="uu_readlink", path="src/uu/readlink" }
realpath = { optional=true, version="0.0.9", package="uu_realpath", path="src/uu/realpath" }
relpath = { optional=true, version="0.0.9", package="uu_relpath", path="src/uu/relpath" }
rm = { optional=true, version="0.0.9", package="uu_rm", path="src/uu/rm" }
rmdir = { optional=true, version="0.0.9", package="uu_rmdir", path="src/uu/rmdir" }
runcon = { optional=true, version="0.0.9", package="uu_runcon", path="src/uu/runcon" }
seq = { optional=true, version="0.0.9", package="uu_seq", path="src/uu/seq" }
shred = { optional=true, version="0.0.9", package="uu_shred", path="src/uu/shred" }
shuf = { optional=true, version="0.0.9", package="uu_shuf", path="src/uu/shuf" }
sleep = { optional=true, version="0.0.9", package="uu_sleep", path="src/uu/sleep" }
sort = { optional=true, version="0.0.9", package="uu_sort", path="src/uu/sort" }
split = { optional=true, version="0.0.9", package="uu_split", path="src/uu/split" }
stat = { optional=true, version="0.0.9", package="uu_stat", path="src/uu/stat" }
stdbuf = { optional=true, version="0.0.9", package="uu_stdbuf", path="src/uu/stdbuf" }
sum = { optional=true, version="0.0.9", package="uu_sum", path="src/uu/sum" }
sync = { optional=true, version="0.0.9", package="uu_sync", path="src/uu/sync" }
tac = { optional=true, version="0.0.9", package="uu_tac", path="src/uu/tac" }
tail = { optional=true, version="0.0.9", package="uu_tail", path="src/uu/tail" }
tee = { optional=true, version="0.0.9", package="uu_tee", path="src/uu/tee" }
timeout = { optional=true, version="0.0.9", package="uu_timeout", path="src/uu/timeout" }
touch = { optional=true, version="0.0.9", package="uu_touch", path="src/uu/touch" }
tr = { optional=true, version="0.0.9", package="uu_tr", path="src/uu/tr" }
true = { optional=true, version="0.0.9", package="uu_true", path="src/uu/true" }
truncate = { optional=true, version="0.0.9", package="uu_truncate", path="src/uu/truncate" }
tsort = { optional=true, version="0.0.9", package="uu_tsort", path="src/uu/tsort" }
tty = { optional=true, version="0.0.9", package="uu_tty", path="src/uu/tty" }
uname = { optional=true, version="0.0.9", package="uu_uname", path="src/uu/uname" }
unexpand = { optional=true, version="0.0.9", package="uu_unexpand", path="src/uu/unexpand" }
uniq = { optional=true, version="0.0.9", package="uu_uniq", path="src/uu/uniq" }
unlink = { optional=true, version="0.0.9", package="uu_unlink", path="src/uu/unlink" }
uptime = { optional=true, version="0.0.9", package="uu_uptime", path="src/uu/uptime" }
users = { optional=true, version="0.0.9", package="uu_users", path="src/uu/users" }
wc = { optional=true, version="0.0.9", package="uu_wc", path="src/uu/wc" }
who = { optional=true, version="0.0.9", package="uu_who", path="src/uu/who" }
whoami = { optional=true, version="0.0.9", package="uu_whoami", path="src/uu/whoami" }
yes = { optional=true, version="0.0.9", package="uu_yes", path="src/uu/yes" }
arch = { optional=true, version="0.0.12", package="uu_arch", path="src/uu/arch" }
base32 = { optional=true, version="0.0.12", package="uu_base32", path="src/uu/base32" }
base64 = { optional=true, version="0.0.12", package="uu_base64", path="src/uu/base64" }
basename = { optional=true, version="0.0.12", package="uu_basename", path="src/uu/basename" }
basenc = { optional=true, version="0.0.12", package="uu_basenc", path="src/uu/basenc" }
cat = { optional=true, version="0.0.12", package="uu_cat", path="src/uu/cat" }
chcon = { optional=true, version="0.0.12", package="uu_chcon", path="src/uu/chcon" }
chgrp = { optional=true, version="0.0.12", package="uu_chgrp", path="src/uu/chgrp" }
chmod = { optional=true, version="0.0.12", package="uu_chmod", path="src/uu/chmod" }
chown = { optional=true, version="0.0.12", package="uu_chown", path="src/uu/chown" }
chroot = { optional=true, version="0.0.12", package="uu_chroot", path="src/uu/chroot" }
cksum = { optional=true, version="0.0.12", package="uu_cksum", path="src/uu/cksum" }
comm = { optional=true, version="0.0.12", package="uu_comm", path="src/uu/comm" }
cp = { optional=true, version="0.0.12", package="uu_cp", path="src/uu/cp" }
csplit = { optional=true, version="0.0.12", package="uu_csplit", path="src/uu/csplit" }
cut = { optional=true, version="0.0.12", package="uu_cut", path="src/uu/cut" }
date = { optional=true, version="0.0.12", package="uu_date", path="src/uu/date" }
dd = { optional=true, version="0.0.12", package="uu_dd", path="src/uu/dd" }
df = { optional=true, version="0.0.12", package="uu_df", path="src/uu/df" }
dircolors= { optional=true, version="0.0.12", package="uu_dircolors", path="src/uu/dircolors" }
dirname = { optional=true, version="0.0.12", package="uu_dirname", path="src/uu/dirname" }
du = { optional=true, version="0.0.12", package="uu_du", path="src/uu/du" }
echo = { optional=true, version="0.0.12", package="uu_echo", path="src/uu/echo" }
env = { optional=true, version="0.0.12", package="uu_env", path="src/uu/env" }
expand = { optional=true, version="0.0.12", package="uu_expand", path="src/uu/expand" }
expr = { optional=true, version="0.0.12", package="uu_expr", path="src/uu/expr" }
factor = { optional=true, version="0.0.12", package="uu_factor", path="src/uu/factor" }
false = { optional=true, version="0.0.12", package="uu_false", path="src/uu/false" }
fmt = { optional=true, version="0.0.12", package="uu_fmt", path="src/uu/fmt" }
fold = { optional=true, version="0.0.12", package="uu_fold", path="src/uu/fold" }
groups = { optional=true, version="0.0.12", package="uu_groups", path="src/uu/groups" }
hashsum = { optional=true, version="0.0.12", package="uu_hashsum", path="src/uu/hashsum" }
head = { optional=true, version="0.0.12", package="uu_head", path="src/uu/head" }
hostid = { optional=true, version="0.0.12", package="uu_hostid", path="src/uu/hostid" }
hostname = { optional=true, version="0.0.12", package="uu_hostname", path="src/uu/hostname" }
id = { optional=true, version="0.0.12", package="uu_id", path="src/uu/id" }
install = { optional=true, version="0.0.12", package="uu_install", path="src/uu/install" }
join = { optional=true, version="0.0.12", package="uu_join", path="src/uu/join" }
kill = { optional=true, version="0.0.12", package="uu_kill", path="src/uu/kill" }
link = { optional=true, version="0.0.12", package="uu_link", path="src/uu/link" }
ln = { optional=true, version="0.0.12", package="uu_ln", path="src/uu/ln" }
ls = { optional=true, version="0.0.12", package="uu_ls", path="src/uu/ls" }
logname = { optional=true, version="0.0.12", package="uu_logname", path="src/uu/logname" }
mkdir = { optional=true, version="0.0.12", package="uu_mkdir", path="src/uu/mkdir" }
mkfifo = { optional=true, version="0.0.12", package="uu_mkfifo", path="src/uu/mkfifo" }
mknod = { optional=true, version="0.0.12", package="uu_mknod", path="src/uu/mknod" }
mktemp = { optional=true, version="0.0.12", package="uu_mktemp", path="src/uu/mktemp" }
more = { optional=true, version="0.0.12", package="uu_more", path="src/uu/more" }
mv = { optional=true, version="0.0.12", package="uu_mv", path="src/uu/mv" }
nice = { optional=true, version="0.0.12", package="uu_nice", path="src/uu/nice" }
nl = { optional=true, version="0.0.12", package="uu_nl", path="src/uu/nl" }
nohup = { optional=true, version="0.0.12", package="uu_nohup", path="src/uu/nohup" }
nproc = { optional=true, version="0.0.12", package="uu_nproc", path="src/uu/nproc" }
numfmt = { optional=true, version="0.0.12", package="uu_numfmt", path="src/uu/numfmt" }
od = { optional=true, version="0.0.12", package="uu_od", path="src/uu/od" }
paste = { optional=true, version="0.0.12", package="uu_paste", path="src/uu/paste" }
pathchk = { optional=true, version="0.0.12", package="uu_pathchk", path="src/uu/pathchk" }
pinky = { optional=true, version="0.0.12", package="uu_pinky", path="src/uu/pinky" }
pr = { optional=true, version="0.0.12", package="uu_pr", path="src/uu/pr" }
printenv = { optional=true, version="0.0.12", package="uu_printenv", path="src/uu/printenv" }
printf = { optional=true, version="0.0.12", package="uu_printf", path="src/uu/printf" }
ptx = { optional=true, version="0.0.12", package="uu_ptx", path="src/uu/ptx" }
pwd = { optional=true, version="0.0.12", package="uu_pwd", path="src/uu/pwd" }
readlink = { optional=true, version="0.0.12", package="uu_readlink", path="src/uu/readlink" }
realpath = { optional=true, version="0.0.12", package="uu_realpath", path="src/uu/realpath" }
relpath = { optional=true, version="0.0.12", package="uu_relpath", path="src/uu/relpath" }
rm = { optional=true, version="0.0.12", package="uu_rm", path="src/uu/rm" }
rmdir = { optional=true, version="0.0.12", package="uu_rmdir", path="src/uu/rmdir" }
runcon = { optional=true, version="0.0.12", package="uu_runcon", path="src/uu/runcon" }
seq = { optional=true, version="0.0.12", package="uu_seq", path="src/uu/seq" }
shred = { optional=true, version="0.0.12", package="uu_shred", path="src/uu/shred" }
shuf = { optional=true, version="0.0.12", package="uu_shuf", path="src/uu/shuf" }
sleep = { optional=true, version="0.0.12", package="uu_sleep", path="src/uu/sleep" }
sort = { optional=true, version="0.0.12", package="uu_sort", path="src/uu/sort" }
split = { optional=true, version="0.0.12", package="uu_split", path="src/uu/split" }
stat = { optional=true, version="0.0.12", package="uu_stat", path="src/uu/stat" }
stdbuf = { optional=true, version="0.0.12", package="uu_stdbuf", path="src/uu/stdbuf" }
sum = { optional=true, version="0.0.12", package="uu_sum", path="src/uu/sum" }
sync = { optional=true, version="0.0.12", package="uu_sync", path="src/uu/sync" }
tac = { optional=true, version="0.0.12", package="uu_tac", path="src/uu/tac" }
tail = { optional=true, version="0.0.12", package="uu_tail", path="src/uu/tail" }
tee = { optional=true, version="0.0.12", package="uu_tee", path="src/uu/tee" }
timeout = { optional=true, version="0.0.12", package="uu_timeout", path="src/uu/timeout" }
touch = { optional=true, version="0.0.12", package="uu_touch", path="src/uu/touch" }
tr = { optional=true, version="0.0.12", package="uu_tr", path="src/uu/tr" }
true = { optional=true, version="0.0.12", package="uu_true", path="src/uu/true" }
truncate = { optional=true, version="0.0.12", package="uu_truncate", path="src/uu/truncate" }
tsort = { optional=true, version="0.0.12", package="uu_tsort", path="src/uu/tsort" }
tty = { optional=true, version="0.0.12", package="uu_tty", path="src/uu/tty" }
uname = { optional=true, version="0.0.12", package="uu_uname", path="src/uu/uname" }
unexpand = { optional=true, version="0.0.12", package="uu_unexpand", path="src/uu/unexpand" }
uniq = { optional=true, version="0.0.12", package="uu_uniq", path="src/uu/uniq" }
unlink = { optional=true, version="0.0.12", package="uu_unlink", path="src/uu/unlink" }
uptime = { optional=true, version="0.0.12", package="uu_uptime", path="src/uu/uptime" }
users = { optional=true, version="0.0.12", package="uu_users", path="src/uu/users" }
wc = { optional=true, version="0.0.12", package="uu_wc", path="src/uu/wc" }
who = { optional=true, version="0.0.12", package="uu_who", path="src/uu/who" }
whoami = { optional=true, version="0.0.12", package="uu_whoami", path="src/uu/whoami" }
yes = { optional=true, version="0.0.12", package="uu_yes", path="src/uu/yes" }
# this breaks clippy linting with: "tests/by-util/test_factor_benches.rs: No such file or directory (os error 2)"
# factor_benches = { optional = true, version = "0.0.0", package = "uu_factor_benches", path = "tests/benches/factor" }

View file

@ -43,7 +43,7 @@ pub fn main() {
let mut tf = File::create(Path::new(&out_dir).join("test_modules.rs")).unwrap();
mf.write_all(
"type UtilityMap<T> = HashMap<&'static str, (fn(T) -> i32, fn() -> App<'static, 'static>)>;\n\
"type UtilityMap<T> = HashMap<&'static str, (fn(T) -> i32, fn() -> App<'static>)>;\n\
\n\
fn util_map<T: uucore::Args>() -> UtilityMap<T> {\n\
\t#[allow(unused_mut)]\n\

View file

@ -5,9 +5,8 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use clap::App;
use clap::Arg;
use clap::Shell;
use clap::{App, Arg};
use clap_complete::Shell;
use std::cmp;
use std::collections::hash_map::HashMap;
use std::ffi::OsStr;
@ -143,13 +142,13 @@ fn gen_completions<T: uucore::Args>(
let matches = App::new("completion")
.about("Prints completions to stdout")
.arg(
Arg::with_name("utility")
.possible_values(&all_utilities)
Arg::new("utility")
.possible_values(all_utilities)
.required(true),
)
.arg(
Arg::with_name("shell")
.possible_values(&Shell::variants())
Arg::new("shell")
.possible_values(Shell::possible_values())
.required(true),
)
.get_matches_from(std::iter::once(OsString::from("completion")).chain(args));
@ -165,12 +164,12 @@ fn gen_completions<T: uucore::Args>(
let shell: Shell = shell.parse().unwrap();
let bin_name = std::env::var("PROG_PREFIX").unwrap_or_default() + utility;
app.gen_completions_to(bin_name, shell, &mut io::stdout());
clap_complete::generate(shell, &mut app, bin_name, &mut io::stdout());
io::stdout().flush().unwrap();
process::exit(0);
}
fn gen_coreutils_app<T: uucore::Args>(util_map: UtilityMap<T>) -> App<'static, 'static> {
fn gen_coreutils_app<T: uucore::Args>(util_map: UtilityMap<T>) -> App<'static> {
let mut app = App::new("coreutils");
for (_, (_, sub_app)) in util_map {
app = app.subcommand(sub_app());

View file

@ -1,6 +1,6 @@
[package]
name = "uu_arch"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "arch ~ (uutils) display machine architecture"
@ -16,7 +16,7 @@ path = "src/arch.rs"
[dependencies]
platform-info = "0.2"
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -23,7 +23,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)

View file

@ -1,6 +1,6 @@
[package]
name = "uu_base32"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "base32 ~ (uutils) decode/encode input (base32-encoding)"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/base32.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -47,6 +47,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
)
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
base_common::base_app(ABOUT)
}

View file

@ -86,33 +86,33 @@ impl Config {
}
pub fn parse_base_cmd_args(args: impl uucore::Args, about: &str, usage: &str) -> UResult<Config> {
let app = base_app(about).usage(usage);
let app = base_app(about).override_usage(usage);
let arg_list = args
.collect_str(InvalidEncodingHandling::ConvertLossy)
.accept_any();
Config::from(&app.get_matches_from(arg_list))
}
pub fn base_app<'a>(about: &'a str) -> App<'static, 'a> {
pub fn base_app(about: &str) -> App {
App::new(uucore::util_name())
.version(crate_version!())
.about(about)
// Format arguments.
.arg(
Arg::with_name(options::DECODE)
.short("d")
Arg::new(options::DECODE)
.short('d')
.long(options::DECODE)
.help("decode data"),
)
.arg(
Arg::with_name(options::IGNORE_GARBAGE)
.short("i")
Arg::new(options::IGNORE_GARBAGE)
.short('i')
.long(options::IGNORE_GARBAGE)
.help("when decoding, ignore non-alphabetic characters"),
)
.arg(
Arg::with_name(options::WRAP)
.short("w")
Arg::new(options::WRAP)
.short('w')
.long(options::WRAP)
.takes_value(true)
.help(
@ -121,7 +121,7 @@ pub fn base_app<'a>(about: &'a str) -> App<'static, 'a> {
)
// "multiple" arguments are used to check whether there is more than one
// file passed in.
.arg(Arg::with_name(options::FILE).index(1).multiple(true))
.arg(Arg::new(options::FILE).index(1).multiple_occurrences(true))
}
pub fn get_input<'a>(config: &Config, stdin_ref: &'a Stdin) -> UResult<Box<dyn Read + 'a>> {

View file

@ -1,6 +1,6 @@
[package]
name = "uu_base64"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "base64 ~ (uutils) decode/encode input (base64-encoding)"
@ -15,7 +15,6 @@ edition = "2018"
path = "src/base64.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
uu_base32 = { version=">=0.0.8", package="uu_base32", path="../base32"}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_basename"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "basename ~ (uutils) display PATHNAME with leading directory components removed"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/basename.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -40,7 +40,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
//
// Argument parsing
//
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
// too few arguments
if !matches.is_present(options::NAME) {
@ -93,27 +93,31 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(SUMMARY)
.arg(
Arg::with_name(options::MULTIPLE)
.short("a")
Arg::new(options::MULTIPLE)
.short('a')
.long(options::MULTIPLE)
.help("support multiple arguments and treat each as a NAME"),
)
.arg(Arg::with_name(options::NAME).multiple(true).hidden(true))
.arg(
Arg::with_name(options::SUFFIX)
.short("s")
Arg::new(options::NAME)
.multiple_occurrences(true)
.hide(true),
)
.arg(
Arg::new(options::SUFFIX)
.short('s')
.long(options::SUFFIX)
.value_name("SUFFIX")
.help("remove a trailing SUFFIX; implies -a"),
)
.arg(
Arg::with_name(options::ZERO)
.short("z")
Arg::new(options::ZERO)
.short('z')
.long(options::ZERO)
.help("end each output line with NUL, not newline"),
)

View file

@ -1,6 +1,6 @@
[package]
name = "uu_basenc"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "basenc ~ (uutils) decode/encode input"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/basenc.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
uu_base32 = { version=">=0.0.8", package="uu_base32", path="../base32"}

View file

@ -45,17 +45,17 @@ fn usage() -> String {
format!("{0} [OPTION]... [FILE]", uucore::execution_phrase())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
let mut app = base_common::base_app(ABOUT);
for encoding in ENCODINGS {
app = app.arg(Arg::with_name(encoding.0).long(encoding.0));
app = app.arg(Arg::new(encoding.0).long(encoding.0));
}
app
}
fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> {
let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(
let matches = uu_app().override_usage(&usage[..]).get_matches_from(
args.collect_str(InvalidEncodingHandling::ConvertLossy)
.accept_any(),
);

View file

@ -1,6 +1,6 @@
[package]
name = "uu_cat"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "cat ~ (uutils) concatenate and display input"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/cat.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
thiserror = "1.0"
atty = "0.2"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "pipes"] }

View file

@ -239,64 +239,68 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
cat_files(files, &options)
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.name(NAME)
.version(crate_version!())
.usage(SYNTAX)
.override_usage(SYNTAX)
.about(SUMMARY)
.arg(Arg::with_name(options::FILE).hidden(true).multiple(true))
.arg(
Arg::with_name(options::SHOW_ALL)
.short("A")
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true),
)
.arg(
Arg::new(options::SHOW_ALL)
.short('A')
.long(options::SHOW_ALL)
.help("equivalent to -vET"),
)
.arg(
Arg::with_name(options::NUMBER_NONBLANK)
.short("b")
Arg::new(options::NUMBER_NONBLANK)
.short('b')
.long(options::NUMBER_NONBLANK)
.help("number nonempty output lines, overrides -n")
.overrides_with(options::NUMBER),
)
.arg(
Arg::with_name(options::SHOW_NONPRINTING_ENDS)
.short("e")
Arg::new(options::SHOW_NONPRINTING_ENDS)
.short('e')
.help("equivalent to -vE"),
)
.arg(
Arg::with_name(options::SHOW_ENDS)
.short("E")
Arg::new(options::SHOW_ENDS)
.short('E')
.long(options::SHOW_ENDS)
.help("display $ at end of each line"),
)
.arg(
Arg::with_name(options::NUMBER)
.short("n")
Arg::new(options::NUMBER)
.short('n')
.long(options::NUMBER)
.help("number all output lines"),
)
.arg(
Arg::with_name(options::SQUEEZE_BLANK)
.short("s")
Arg::new(options::SQUEEZE_BLANK)
.short('s')
.long(options::SQUEEZE_BLANK)
.help("suppress repeated empty output lines"),
)
.arg(
Arg::with_name(options::SHOW_NONPRINTING_TABS)
.short("t")
Arg::new(options::SHOW_NONPRINTING_TABS)
.short('t')
.long(options::SHOW_NONPRINTING_TABS)
.help("equivalent to -vT"),
)
.arg(
Arg::with_name(options::SHOW_TABS)
.short("T")
Arg::new(options::SHOW_TABS)
.short('T')
.long(options::SHOW_TABS)
.help("display TAB characters at ^I"),
)
.arg(
Arg::with_name(options::SHOW_NONPRINTING)
.short("v")
Arg::new(options::SHOW_NONPRINTING)
.short('v')
.long(options::SHOW_NONPRINTING)
.help("use ^ and M- notation, except for LF (\\n) and TAB (\\t)"),
)

View file

@ -1,6 +1,6 @@
[package]
name = "uu_chcon"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "chcon ~ (uutils) change file security context"
@ -14,7 +14,7 @@ edition = "2018"
path = "src/chcon.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version = ">=0.0.9", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] }
uucore_procs = { version = ">=0.0.6", package="uucore_procs", path="../../uucore_procs" }
selinux = { version = "0.2" }

View file

@ -65,14 +65,14 @@ fn get_usage() -> String {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = get_usage();
let config = uu_app().usage(usage.as_ref());
let config = uu_app().override_usage(usage.as_ref());
let options = match parse_command_line(config, args) {
Ok(r) => r,
Err(r) => {
if let Error::CommandLine(r) = &r {
match r.kind {
clap::ErrorKind::HelpDisplayed | clap::ErrorKind::VersionDisplayed => {
clap::ErrorKind::DisplayHelp | clap::ErrorKind::DisplayVersion => {
println!("{}", r);
return Ok(());
}
@ -160,12 +160,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Err(libc::EXIT_FAILURE.into())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(VERSION)
.about(ABOUT)
.arg(
Arg::with_name(options::dereference::DEREFERENCE)
Arg::new(options::dereference::DEREFERENCE)
.long(options::dereference::DEREFERENCE)
.conflicts_with(options::dereference::NO_DEREFERENCE)
.help(
@ -174,24 +174,24 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(options::dereference::NO_DEREFERENCE)
.short("h")
Arg::new(options::dereference::NO_DEREFERENCE)
.short('h')
.long(options::dereference::NO_DEREFERENCE)
.help("Affect symbolic links instead of any referenced file."),
)
.arg(
Arg::with_name(options::preserve_root::PRESERVE_ROOT)
Arg::new(options::preserve_root::PRESERVE_ROOT)
.long(options::preserve_root::PRESERVE_ROOT)
.conflicts_with(options::preserve_root::NO_PRESERVE_ROOT)
.help("Fail to operate recursively on '/'."),
)
.arg(
Arg::with_name(options::preserve_root::NO_PRESERVE_ROOT)
Arg::new(options::preserve_root::NO_PRESERVE_ROOT)
.long(options::preserve_root::NO_PRESERVE_ROOT)
.help("Do not treat '/' specially (the default)."),
)
.arg(
Arg::with_name(options::REFERENCE)
Arg::new(options::REFERENCE)
.long(options::REFERENCE)
.takes_value(true)
.value_name("RFILE")
@ -199,49 +199,54 @@ pub fn uu_app() -> App<'static, 'static> {
.help(
"Use security context of RFILE, rather than specifying \
a CONTEXT value.",
),
)
.allow_invalid_utf8(true),
)
.arg(
Arg::with_name(options::USER)
.short("u")
Arg::new(options::USER)
.short('u')
.long(options::USER)
.takes_value(true)
.value_name("USER")
.help("Set user USER in the target security context."),
.help("Set user USER in the target security context.")
.allow_invalid_utf8(true),
)
.arg(
Arg::with_name(options::ROLE)
.short("r")
Arg::new(options::ROLE)
.short('r')
.long(options::ROLE)
.takes_value(true)
.value_name("ROLE")
.help("Set role ROLE in the target security context."),
.help("Set role ROLE in the target security context.")
.allow_invalid_utf8(true),
)
.arg(
Arg::with_name(options::TYPE)
.short("t")
Arg::new(options::TYPE)
.short('t')
.long(options::TYPE)
.takes_value(true)
.value_name("TYPE")
.help("Set type TYPE in the target security context."),
.help("Set type TYPE in the target security context.")
.allow_invalid_utf8(true),
)
.arg(
Arg::with_name(options::RANGE)
.short("l")
Arg::new(options::RANGE)
.short('l')
.long(options::RANGE)
.takes_value(true)
.value_name("RANGE")
.help("Set range RANGE in the target security context."),
.help("Set range RANGE in the target security context.")
.allow_invalid_utf8(true),
)
.arg(
Arg::with_name(options::RECURSIVE)
.short("R")
Arg::new(options::RECURSIVE)
.short('R')
.long(options::RECURSIVE)
.help("Operate on files and directories recursively."),
)
.arg(
Arg::with_name(options::sym_links::FOLLOW_ARG_DIR_SYM_LINK)
.short("H")
Arg::new(options::sym_links::FOLLOW_ARG_DIR_SYM_LINK)
.short('H')
.requires(options::RECURSIVE)
.overrides_with_all(&[
options::sym_links::FOLLOW_DIR_SYM_LINKS,
@ -253,8 +258,8 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(options::sym_links::FOLLOW_DIR_SYM_LINKS)
.short("L")
Arg::new(options::sym_links::FOLLOW_DIR_SYM_LINKS)
.short('L')
.requires(options::RECURSIVE)
.overrides_with_all(&[
options::sym_links::FOLLOW_ARG_DIR_SYM_LINK,
@ -266,8 +271,8 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(options::sym_links::NO_FOLLOW_SYM_LINKS)
.short("P")
Arg::new(options::sym_links::NO_FOLLOW_SYM_LINKS)
.short('P')
.requires(options::RECURSIVE)
.overrides_with_all(&[
options::sym_links::FOLLOW_ARG_DIR_SYM_LINK,
@ -279,12 +284,17 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(options::VERBOSE)
.short("v")
Arg::new(options::VERBOSE)
.short('v')
.long(options::VERBOSE)
.help("Output a diagnostic for every file processed."),
)
.arg(Arg::with_name("FILE").multiple(true).min_values(1))
.arg(
Arg::new("FILE")
.multiple_occurrences(true)
.min_values(1)
.allow_invalid_utf8(true),
)
}
#[derive(Debug)]
@ -298,7 +308,7 @@ struct Options {
}
fn parse_command_line(config: clap::App, args: impl uucore::Args) -> Result<Options> {
let matches = config.get_matches_from_safe(args)?;
let matches = config.try_get_matches_from(args)?;
let verbose = matches.is_present(options::VERBOSE);

View file

@ -1,6 +1,6 @@
[package]
name = "uu_chgrp"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "chgrp ~ (uutils) change the group ownership of FILE"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/chgrp.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -56,7 +56,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = get_usage();
chown_base(
uu_app().usage(&usage[..]),
uu_app().override_usage(&usage[..]),
args,
options::ARG_GROUP,
parse_gid_and_uid,
@ -64,82 +64,82 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
)
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(VERSION)
.about(ABOUT)
.arg(
Arg::with_name(options::verbosity::CHANGES)
.short("c")
Arg::new(options::verbosity::CHANGES)
.short('c')
.long(options::verbosity::CHANGES)
.help("like verbose but report only when a change is made"),
)
.arg(
Arg::with_name(options::verbosity::SILENT)
.short("f")
Arg::new(options::verbosity::SILENT)
.short('f')
.long(options::verbosity::SILENT),
)
.arg(
Arg::with_name(options::verbosity::QUIET)
Arg::new(options::verbosity::QUIET)
.long(options::verbosity::QUIET)
.help("suppress most error messages"),
)
.arg(
Arg::with_name(options::verbosity::VERBOSE)
.short("v")
Arg::new(options::verbosity::VERBOSE)
.short('v')
.long(options::verbosity::VERBOSE)
.help("output a diagnostic for every file processed"),
)
.arg(
Arg::with_name(options::dereference::DEREFERENCE)
Arg::new(options::dereference::DEREFERENCE)
.long(options::dereference::DEREFERENCE),
)
.arg(
Arg::with_name(options::dereference::NO_DEREFERENCE)
.short("h")
Arg::new(options::dereference::NO_DEREFERENCE)
.short('h')
.long(options::dereference::NO_DEREFERENCE)
.help(
"affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)",
),
)
.arg(
Arg::with_name(options::preserve_root::PRESERVE)
Arg::new(options::preserve_root::PRESERVE)
.long(options::preserve_root::PRESERVE)
.help("fail to operate recursively on '/'"),
)
.arg(
Arg::with_name(options::preserve_root::NO_PRESERVE)
Arg::new(options::preserve_root::NO_PRESERVE)
.long(options::preserve_root::NO_PRESERVE)
.help("do not treat '/' specially (the default)"),
)
.arg(
Arg::with_name(options::REFERENCE)
Arg::new(options::REFERENCE)
.long(options::REFERENCE)
.value_name("RFILE")
.help("use RFILE's group rather than specifying GROUP values")
.takes_value(true)
.multiple(false),
.multiple_occurrences(false),
)
.arg(
Arg::with_name(options::RECURSIVE)
.short("R")
Arg::new(options::RECURSIVE)
.short('R')
.long(options::RECURSIVE)
.help("operate on files and directories recursively"),
)
.arg(
Arg::with_name(options::traverse::TRAVERSE)
.short(options::traverse::TRAVERSE)
Arg::new(options::traverse::TRAVERSE)
.short(options::traverse::TRAVERSE.chars().next().unwrap())
.help("if a command line argument is a symbolic link to a directory, traverse it"),
)
.arg(
Arg::with_name(options::traverse::NO_TRAVERSE)
.short(options::traverse::NO_TRAVERSE)
Arg::new(options::traverse::NO_TRAVERSE)
.short(options::traverse::NO_TRAVERSE.chars().next().unwrap())
.help("do not traverse any symbolic links (default)")
.overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::EVERY]),
)
.arg(
Arg::with_name(options::traverse::EVERY)
.short(options::traverse::EVERY)
Arg::new(options::traverse::EVERY)
.short(options::traverse::EVERY.chars().next().unwrap())
.help("traverse every symbolic link to a directory encountered"),
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_chmod"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "chmod ~ (uutils) change mode of FILE"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/chmod.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -62,7 +62,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let after_help = get_long_usage();
let matches = uu_app()
.usage(&usage[..])
.override_usage(&usage[..])
.after_help(&after_help[..])
.get_matches_from(args);
@ -121,63 +121,63 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
chmoder.chmod(files)
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(options::CHANGES)
Arg::new(options::CHANGES)
.long(options::CHANGES)
.short("c")
.short('c')
.help("like verbose but report only when a change is made"),
)
.arg(
Arg::with_name(options::QUIET)
Arg::new(options::QUIET)
.long(options::QUIET)
.visible_alias("silent")
.short("f")
.short('f')
.help("suppress most error messages"),
)
.arg(
Arg::with_name(options::VERBOSE)
Arg::new(options::VERBOSE)
.long(options::VERBOSE)
.short("v")
.short('v')
.help("output a diagnostic for every file processed"),
)
.arg(
Arg::with_name(options::NO_PRESERVE_ROOT)
Arg::new(options::NO_PRESERVE_ROOT)
.long(options::NO_PRESERVE_ROOT)
.help("do not treat '/' specially (the default)"),
)
.arg(
Arg::with_name(options::PRESERVE_ROOT)
Arg::new(options::PRESERVE_ROOT)
.long(options::PRESERVE_ROOT)
.help("fail to operate recursively on '/'"),
)
.arg(
Arg::with_name(options::RECURSIVE)
Arg::new(options::RECURSIVE)
.long(options::RECURSIVE)
.short("R")
.short('R')
.help("change files and directories recursively"),
)
.arg(
Arg::with_name(options::REFERENCE)
Arg::new(options::REFERENCE)
.long("reference")
.takes_value(true)
.help("use RFILE's mode instead of MODE values"),
)
.arg(
Arg::with_name(options::MODE)
.required_unless(options::REFERENCE)
Arg::new(options::MODE)
.required_unless_present(options::REFERENCE)
.takes_value(true),
// It would be nice if clap could parse with delimiter, e.g. "g-x,u+x",
// however .multiple(true) cannot be used here because FILE already needs that.
// Only one positional argument with .multiple(true) set is allowed per command
// however .multiple_occurrences(true) cannot be used here because FILE already needs that.
// Only one positional argument with .multiple_occurrences(true) set is allowed per command
)
.arg(
Arg::with_name(options::FILE)
.required_unless(options::MODE)
.multiple(true),
Arg::new(options::FILE)
.required_unless_present(options::MODE)
.multiple_occurrences(true),
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_chown"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "chown ~ (uutils) change the ownership of FILE"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/chown.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -59,7 +59,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = get_usage();
chown_base(
uu_app().usage(&usage[..]),
uu_app().override_usage(&usage[..]),
args,
options::ARG_OWNER,
parse_gid_uid_and_filter,
@ -67,18 +67,18 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
)
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(options::verbosity::CHANGES)
.short("c")
Arg::new(options::verbosity::CHANGES)
.short('c')
.long(options::verbosity::CHANGES)
.help("like verbose but report only when a change is made"),
)
.arg(
Arg::with_name(options::dereference::DEREFERENCE)
Arg::new(options::dereference::DEREFERENCE)
.long(options::dereference::DEREFERENCE)
.help(
"affect the referent of each symbolic link (this is the default), \
@ -86,8 +86,8 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(options::dereference::NO_DEREFERENCE)
.short("h")
Arg::new(options::dereference::NO_DEREFERENCE)
.short('h')
.long(options::dereference::NO_DEREFERENCE)
.help(
"affect symbolic links instead of any referenced file \
@ -95,7 +95,7 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(options::FROM)
Arg::new(options::FROM)
.long(options::FROM)
.help(
"change the owner and/or group of each file only if its \
@ -106,60 +106,60 @@ pub fn uu_app() -> App<'static, 'static> {
.value_name("CURRENT_OWNER:CURRENT_GROUP"),
)
.arg(
Arg::with_name(options::preserve_root::PRESERVE)
Arg::new(options::preserve_root::PRESERVE)
.long(options::preserve_root::PRESERVE)
.help("fail to operate recursively on '/'"),
)
.arg(
Arg::with_name(options::preserve_root::NO_PRESERVE)
Arg::new(options::preserve_root::NO_PRESERVE)
.long(options::preserve_root::NO_PRESERVE)
.help("do not treat '/' specially (the default)"),
)
.arg(
Arg::with_name(options::verbosity::QUIET)
Arg::new(options::verbosity::QUIET)
.long(options::verbosity::QUIET)
.help("suppress most error messages"),
)
.arg(
Arg::with_name(options::RECURSIVE)
.short("R")
Arg::new(options::RECURSIVE)
.short('R')
.long(options::RECURSIVE)
.help("operate on files and directories recursively"),
)
.arg(
Arg::with_name(options::REFERENCE)
Arg::new(options::REFERENCE)
.long(options::REFERENCE)
.help("use RFILE's owner and group rather than specifying OWNER:GROUP values")
.value_name("RFILE")
.min_values(1),
)
.arg(
Arg::with_name(options::verbosity::SILENT)
.short("f")
Arg::new(options::verbosity::SILENT)
.short('f')
.long(options::verbosity::SILENT),
)
.arg(
Arg::with_name(options::traverse::TRAVERSE)
.short(options::traverse::TRAVERSE)
Arg::new(options::traverse::TRAVERSE)
.short(options::traverse::TRAVERSE.chars().next().unwrap())
.help("if a command line argument is a symbolic link to a directory, traverse it")
.overrides_with_all(&[options::traverse::EVERY, options::traverse::NO_TRAVERSE]),
)
.arg(
Arg::with_name(options::traverse::EVERY)
.short(options::traverse::EVERY)
Arg::new(options::traverse::EVERY)
.short(options::traverse::EVERY.chars().next().unwrap())
.help("traverse every symbolic link to a directory encountered")
.overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::NO_TRAVERSE]),
)
.arg(
Arg::with_name(options::traverse::NO_TRAVERSE)
.short(options::traverse::NO_TRAVERSE)
Arg::new(options::traverse::NO_TRAVERSE)
.short(options::traverse::NO_TRAVERSE.chars().next().unwrap())
.help("do not traverse any symbolic links (default)")
.overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::EVERY]),
)
.arg(
Arg::with_name(options::verbosity::VERBOSE)
Arg::new(options::verbosity::VERBOSE)
.long(options::verbosity::VERBOSE)
.short("v")
.short('v')
.help("output a diagnostic for every file processed"),
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_chroot"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "chroot ~ (uutils) run COMMAND under a new root directory"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/chroot.rs"
[dependencies]
clap= "2.33"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -91,40 +91,40 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.usage(SYNTAX)
.override_usage(SYNTAX)
.arg(
Arg::with_name(options::NEWROOT)
.hidden(true)
Arg::new(options::NEWROOT)
.hide(true)
.required(true)
.index(1),
)
.arg(
Arg::with_name(options::USER)
.short("u")
Arg::new(options::USER)
.short('u')
.long(options::USER)
.help("User (ID or name) to switch before running the program")
.value_name("USER"),
)
.arg(
Arg::with_name(options::GROUP)
.short("g")
Arg::new(options::GROUP)
.short('g')
.long(options::GROUP)
.help("Group (ID or name) to switch to")
.value_name("GROUP"),
)
.arg(
Arg::with_name(options::GROUPS)
.short("G")
Arg::new(options::GROUPS)
.short('G')
.long(options::GROUPS)
.help("Comma-separated list of groups to switch to")
.value_name("GROUP1,GROUP2..."),
)
.arg(
Arg::with_name(options::USERSPEC)
Arg::new(options::USERSPEC)
.long(options::USERSPEC)
.help(
"Colon-separated user and group to switch to. \
@ -134,9 +134,9 @@ pub fn uu_app() -> App<'static, 'static> {
.value_name("USER:GROUP"),
)
.arg(
Arg::with_name(options::COMMAND)
.hidden(true)
.multiple(true)
Arg::new(options::COMMAND)
.hide(true)
.multiple_occurrences(true)
.index(2),
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_cksum"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "cksum ~ (uutils) display CRC and size of input"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/cksum.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -140,11 +140,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.name(NAME)
.version(crate_version!())
.about(SUMMARY)
.usage(SYNTAX)
.arg(Arg::with_name(options::FILE).hidden(true).multiple(true))
.override_usage(SYNTAX)
.arg(
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true),
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_comm"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "comm ~ (uutils) compare sorted inputs"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/comm.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -137,7 +137,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.collect_str(InvalidEncodingHandling::ConvertLossy)
.accept_any();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let filename1 = matches.value_of(options::FILE_1).unwrap();
let filename2 = matches.value_of(options::FILE_2).unwrap();
let mut f1 = open_file(filename1).map_err_context(|| filename1.to_string())?;
@ -147,34 +147,34 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.after_help(LONG_HELP)
.arg(
Arg::with_name(options::COLUMN_1)
.short(options::COLUMN_1)
Arg::new(options::COLUMN_1)
.short('1')
.help("suppress column 1 (lines unique to FILE1)"),
)
.arg(
Arg::with_name(options::COLUMN_2)
.short(options::COLUMN_2)
Arg::new(options::COLUMN_2)
.short('2')
.help("suppress column 2 (lines unique to FILE2)"),
)
.arg(
Arg::with_name(options::COLUMN_3)
.short(options::COLUMN_3)
Arg::new(options::COLUMN_3)
.short('3')
.help("suppress column 3 (lines that appear in both files)"),
)
.arg(
Arg::with_name(options::DELIMITER)
Arg::new(options::DELIMITER)
.long(options::DELIMITER)
.help("separate columns with STR")
.value_name("STR")
.default_value(options::DELIMITER_DEFAULT)
.hide_default_value(true),
)
.arg(Arg::with_name(options::FILE_1).required(true))
.arg(Arg::with_name(options::FILE_2).required(true))
.arg(Arg::new(options::FILE_1).required(true))
.arg(Arg::new(options::FILE_2).required(true))
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_cp"
version = "0.0.9"
version = "0.0.12"
authors = [
"Jordy Dickinson <jordy.dickinson@gmail.com>",
"Joshua S. Miller <jsmiller@uchicago.edu>",
@ -19,7 +19,7 @@ edition = "2018"
path = "src/cp.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
filetime = "0.2"
libc = "0.2.85"
quick-error = "1.2.3"

View file

@ -296,65 +296,65 @@ static DEFAULT_ATTRIBUTES: &[Attribute] = &[
Attribute::Timestamps,
];
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(Arg::with_name(options::TARGET_DIRECTORY)
.short("t")
.arg(Arg::new(options::TARGET_DIRECTORY)
.short('t')
.conflicts_with(options::NO_TARGET_DIRECTORY)
.long(options::TARGET_DIRECTORY)
.value_name(options::TARGET_DIRECTORY)
.takes_value(true)
.help("copy all SOURCE arguments into target-directory"))
.arg(Arg::with_name(options::NO_TARGET_DIRECTORY)
.short("T")
.arg(Arg::new(options::NO_TARGET_DIRECTORY)
.short('T')
.long(options::NO_TARGET_DIRECTORY)
.conflicts_with(options::TARGET_DIRECTORY)
.help("Treat DEST as a regular file and not a directory"))
.arg(Arg::with_name(options::INTERACTIVE)
.short("i")
.arg(Arg::new(options::INTERACTIVE)
.short('i')
.long(options::INTERACTIVE)
.conflicts_with(options::NO_CLOBBER)
.help("ask before overwriting files"))
.arg(Arg::with_name(options::LINK)
.short("l")
.arg(Arg::new(options::LINK)
.short('l')
.long(options::LINK)
.overrides_with(options::REFLINK)
.help("hard-link files instead of copying"))
.arg(Arg::with_name(options::NO_CLOBBER)
.short("n")
.arg(Arg::new(options::NO_CLOBBER)
.short('n')
.long(options::NO_CLOBBER)
.conflicts_with(options::INTERACTIVE)
.help("don't overwrite a file that already exists"))
.arg(Arg::with_name(options::RECURSIVE)
.short("r")
.arg(Arg::new(options::RECURSIVE)
.short('r')
.long(options::RECURSIVE)
// --archive sets this option
.help("copy directories recursively"))
.arg(Arg::with_name(options::RECURSIVE_ALIAS)
.short("R")
.arg(Arg::new(options::RECURSIVE_ALIAS)
.short('R')
.help("same as -r"))
.arg(Arg::with_name(options::STRIP_TRAILING_SLASHES)
.arg(Arg::new(options::STRIP_TRAILING_SLASHES)
.long(options::STRIP_TRAILING_SLASHES)
.help("remove any trailing slashes from each SOURCE argument"))
.arg(Arg::with_name(options::VERBOSE)
.short("v")
.arg(Arg::new(options::VERBOSE)
.short('v')
.long(options::VERBOSE)
.help("explicitly state what is being done"))
.arg(Arg::with_name(options::SYMBOLIC_LINK)
.short("s")
.arg(Arg::new(options::SYMBOLIC_LINK)
.short('s')
.long(options::SYMBOLIC_LINK)
.conflicts_with(options::LINK)
.overrides_with(options::REFLINK)
.help("make symbolic links instead of copying"))
.arg(Arg::with_name(options::FORCE)
.short("f")
.arg(Arg::new(options::FORCE)
.short('f')
.long(options::FORCE)
.help("if an existing destination file cannot be opened, remove it and \
try again (this option is ignored when the -n option is also used). \
Currently not implemented for Windows."))
.arg(Arg::with_name(options::REMOVE_DESTINATION)
.arg(Arg::new(options::REMOVE_DESTINATION)
.long(options::REMOVE_DESTINATION)
.conflicts_with(options::FORCE)
.help("remove each existing destination file before attempting to open it \
@ -362,25 +362,25 @@ pub fn uu_app() -> App<'static, 'static> {
.arg(backup_control::arguments::backup())
.arg(backup_control::arguments::backup_no_args())
.arg(backup_control::arguments::suffix())
.arg(Arg::with_name(options::UPDATE)
.short("u")
.arg(Arg::new(options::UPDATE)
.short('u')
.long(options::UPDATE)
.help("copy only when the SOURCE file is newer than the destination file \
or when the destination file is missing"))
.arg(Arg::with_name(options::REFLINK)
.arg(Arg::new(options::REFLINK)
.long(options::REFLINK)
.takes_value(true)
.value_name("WHEN")
.help("control clone/CoW copies. See below"))
.arg(Arg::with_name(options::ATTRIBUTES_ONLY)
.arg(Arg::new(options::ATTRIBUTES_ONLY)
.long(options::ATTRIBUTES_ONLY)
.conflicts_with(options::COPY_CONTENTS)
.overrides_with(options::REFLINK)
.help("Don't copy the file data, just the attributes"))
.arg(Arg::with_name(options::PRESERVE)
.arg(Arg::new(options::PRESERVE)
.long(options::PRESERVE)
.takes_value(true)
.multiple(true)
.multiple_occurrences(true)
.use_delimiter(true)
.possible_values(PRESERVABLE_ATTRIBUTES)
.min_values(0)
@ -390,67 +390,67 @@ pub fn uu_app() -> App<'static, 'static> {
// --archive sets this option
.help("Preserve the specified attributes (default: mode, ownership (unix only), timestamps), \
if possible additional attributes: context, links, xattr, all"))
.arg(Arg::with_name(options::PRESERVE_DEFAULT_ATTRIBUTES)
.short("-p")
.arg(Arg::new(options::PRESERVE_DEFAULT_ATTRIBUTES)
.short('p')
.long(options::PRESERVE_DEFAULT_ATTRIBUTES)
.conflicts_with_all(&[options::PRESERVE, options::NO_PRESERVE, options::ARCHIVE])
.help("same as --preserve=mode,ownership(unix only),timestamps"))
.arg(Arg::with_name(options::NO_PRESERVE)
.arg(Arg::new(options::NO_PRESERVE)
.long(options::NO_PRESERVE)
.takes_value(true)
.value_name("ATTR_LIST")
.conflicts_with_all(&[options::PRESERVE_DEFAULT_ATTRIBUTES, options::PRESERVE, options::ARCHIVE])
.help("don't preserve the specified attributes"))
.arg(Arg::with_name(options::PARENTS)
.arg(Arg::new(options::PARENTS)
.long(options::PARENTS)
.alias(options::PARENT)
.help("use full source file name under DIRECTORY"))
.arg(Arg::with_name(options::NO_DEREFERENCE)
.short("-P")
.arg(Arg::new(options::NO_DEREFERENCE)
.short('P')
.long(options::NO_DEREFERENCE)
.conflicts_with(options::DEREFERENCE)
// -d sets this option
.help("never follow symbolic links in SOURCE"))
.arg(Arg::with_name(options::DEREFERENCE)
.short("L")
.arg(Arg::new(options::DEREFERENCE)
.short('L')
.long(options::DEREFERENCE)
.conflicts_with(options::NO_DEREFERENCE)
.help("always follow symbolic links in SOURCE"))
.arg(Arg::with_name(options::ARCHIVE)
.short("a")
.arg(Arg::new(options::ARCHIVE)
.short('a')
.long(options::ARCHIVE)
.conflicts_with_all(&[options::PRESERVE_DEFAULT_ATTRIBUTES, options::PRESERVE, options::NO_PRESERVE])
.help("Same as -dR --preserve=all"))
.arg(Arg::with_name(options::NO_DEREFERENCE_PRESERVE_LINKS)
.short("d")
.arg(Arg::new(options::NO_DEREFERENCE_PRESERVE_LINKS)
.short('d')
.help("same as --no-dereference --preserve=links"))
.arg(Arg::with_name(options::ONE_FILE_SYSTEM)
.short("x")
.arg(Arg::new(options::ONE_FILE_SYSTEM)
.short('x')
.long(options::ONE_FILE_SYSTEM)
.help("stay on this file system"))
// TODO: implement the following args
.arg(Arg::with_name(options::COPY_CONTENTS)
.arg(Arg::new(options::COPY_CONTENTS)
.long(options::COPY_CONTENTS)
.conflicts_with(options::ATTRIBUTES_ONLY)
.help("NotImplemented: copy contents of special files when recursive"))
.arg(Arg::with_name(options::SPARSE)
.arg(Arg::new(options::SPARSE)
.long(options::SPARSE)
.takes_value(true)
.value_name("WHEN")
.help("NotImplemented: control creation of sparse files. See below"))
.arg(Arg::with_name(options::CONTEXT)
.arg(Arg::new(options::CONTEXT)
.long(options::CONTEXT)
.takes_value(true)
.value_name("CTX")
.help("NotImplemented: set SELinux security context of destination file to default type"))
.arg(Arg::with_name(options::CLI_SYMBOLIC_LINKS)
.short("H")
.arg(Arg::new(options::CLI_SYMBOLIC_LINKS)
.short('H')
.help("NotImplemented: follow command-line symbolic links in SOURCE"))
// END TODO
.arg(Arg::with_name(options::PATHS)
.multiple(true))
.arg(Arg::new(options::PATHS)
.multiple_occurrences(true))
}
#[uucore_procs::gen_uumain]
@ -462,7 +462,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
LONG_HELP,
backup_control::BACKUP_CONTROL_LONG_HELP
))
.usage(&usage[..])
.override_usage(&usage[..])
.get_matches_from(args);
let options = Options::from_matches(&matches)?;

View file

@ -1,6 +1,6 @@
[package]
name = "uu_csplit"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "csplit ~ (uutils) Output pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/csplit.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
thiserror = "1.0"
regex = "1.0.0"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs"] }

View file

@ -722,7 +722,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.collect_str(InvalidEncodingHandling::Ignore)
.accept_any();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
// get the file to split
let file_name = matches.value_of(options::FILE).unwrap();
@ -751,60 +751,60 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(SUMMARY)
.arg(
Arg::with_name(options::SUFFIX_FORMAT)
.short("b")
Arg::new(options::SUFFIX_FORMAT)
.short('b')
.long(options::SUFFIX_FORMAT)
.value_name("FORMAT")
.help("use sprintf FORMAT instead of %02d"),
)
.arg(
Arg::with_name(options::PREFIX)
.short("f")
Arg::new(options::PREFIX)
.short('f')
.long(options::PREFIX)
.value_name("PREFIX")
.help("use PREFIX instead of 'xx'"),
)
.arg(
Arg::with_name(options::KEEP_FILES)
.short("k")
Arg::new(options::KEEP_FILES)
.short('k')
.long(options::KEEP_FILES)
.help("do not remove output files on errors"),
)
.arg(
Arg::with_name(options::SUPPRESS_MATCHED)
Arg::new(options::SUPPRESS_MATCHED)
.long(options::SUPPRESS_MATCHED)
.help("suppress the lines matching PATTERN"),
)
.arg(
Arg::with_name(options::DIGITS)
.short("n")
Arg::new(options::DIGITS)
.short('n')
.long(options::DIGITS)
.value_name("DIGITS")
.help("use specified number of digits instead of 2"),
)
.arg(
Arg::with_name(options::QUIET)
.short("s")
Arg::new(options::QUIET)
.short('s')
.long(options::QUIET)
.visible_alias("silent")
.help("do not print counts of output file sizes"),
)
.arg(
Arg::with_name(options::ELIDE_EMPTY_FILES)
.short("z")
Arg::new(options::ELIDE_EMPTY_FILES)
.short('z')
.long(options::ELIDE_EMPTY_FILES)
.help("remove empty output files"),
)
.arg(Arg::with_name(options::FILE).hidden(true).required(true))
.arg(Arg::new(options::FILE).hide(true).required(true))
.arg(
Arg::with_name(options::PATTERN)
.hidden(true)
.multiple(true)
Arg::new(options::PATTERN)
.hide(true)
.multiple_occurrences(true)
.required(true),
)
.after_help(LONG_HELP)

View file

@ -1,6 +1,6 @@
[package]
name = "uu_cut"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "cut ~ (uutils) display byte/field columns of input lines"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/cut.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
memchr = "2"

View file

@ -532,16 +532,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.name(NAME)
.version(crate_version!())
.usage(SYNTAX)
.override_usage(SYNTAX)
.about(SUMMARY)
.after_help(LONG_HELP)
.arg(
Arg::with_name(options::BYTES)
.short("b")
Arg::new(options::BYTES)
.short('b')
.long(options::BYTES)
.takes_value(true)
.help("filter byte columns from the input source")
@ -550,8 +550,8 @@ pub fn uu_app() -> App<'static, 'static> {
.display_order(1),
)
.arg(
Arg::with_name(options::CHARACTERS)
.short("c")
Arg::new(options::CHARACTERS)
.short('c')
.long(options::CHARACTERS)
.help("alias for character mode")
.takes_value(true)
@ -560,8 +560,8 @@ pub fn uu_app() -> App<'static, 'static> {
.display_order(2),
)
.arg(
Arg::with_name(options::DELIMITER)
.short("d")
Arg::new(options::DELIMITER)
.short('d')
.long(options::DELIMITER)
.help("specify the delimiter character that separates fields in the input source. Defaults to Tab.")
.takes_value(true)
@ -569,8 +569,8 @@ pub fn uu_app() -> App<'static, 'static> {
.display_order(3),
)
.arg(
Arg::with_name(options::FIELDS)
.short("f")
Arg::new(options::FIELDS)
.short('f')
.long(options::FIELDS)
.help("filter field columns from the input source")
.takes_value(true)
@ -579,30 +579,30 @@ pub fn uu_app() -> App<'static, 'static> {
.display_order(4),
)
.arg(
Arg::with_name(options::COMPLEMENT)
Arg::new(options::COMPLEMENT)
.long(options::COMPLEMENT)
.help("invert the filter - instead of displaying only the filtered columns, display all but those columns")
.takes_value(false)
.display_order(5),
)
.arg(
Arg::with_name(options::ONLY_DELIMITED)
.short("s")
Arg::new(options::ONLY_DELIMITED)
.short('s')
.long(options::ONLY_DELIMITED)
.help("in field mode, only print lines which contain the delimiter")
.takes_value(false)
.display_order(6),
)
.arg(
Arg::with_name(options::ZERO_TERMINATED)
.short("z")
Arg::new(options::ZERO_TERMINATED)
.short('z')
.long(options::ZERO_TERMINATED)
.help("instead of filtering columns based on line, filter columns based on \\0 (NULL character)")
.takes_value(false)
.display_order(8),
)
.arg(
Arg::with_name(options::OUTPUT_DELIMITER)
Arg::new(options::OUTPUT_DELIMITER)
.long(options::OUTPUT_DELIMITER)
.help("in field mode, replace the delimiter in output lines with this option's argument")
.takes_value(true)
@ -610,8 +610,8 @@ pub fn uu_app() -> App<'static, 'static> {
.display_order(7),
)
.arg(
Arg::with_name(options::FILE)
.hidden(true)
.multiple(true)
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true)
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_date"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "date ~ (uutils) display or set the current time"
@ -16,7 +16,7 @@ path = "src/date.rs"
[dependencies]
chrono = "^0.4.11"
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -147,7 +147,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
{0} [OPTION]... [MMDDhhmm[[CC]YY][.ss]]",
NAME
);
let matches = uu_app().usage(&syntax[..]).get_matches_from(args);
let matches = uu_app().override_usage(&syntax[..]).get_matches_from(args);
let format = if let Some(form) = matches.value_of(OPT_FORMAT) {
if !form.starts_with('+') {
@ -257,70 +257,70 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(OPT_DATE)
.short("d")
Arg::new(OPT_DATE)
.short('d')
.long(OPT_DATE)
.takes_value(true)
.help("display time described by STRING, not 'now'"),
)
.arg(
Arg::with_name(OPT_FILE)
.short("f")
Arg::new(OPT_FILE)
.short('f')
.long(OPT_FILE)
.takes_value(true)
.help("like --date; once for each line of DATEFILE"),
)
.arg(
Arg::with_name(OPT_ISO_8601)
.short("I")
Arg::new(OPT_ISO_8601)
.short('I')
.long(OPT_ISO_8601)
.takes_value(true)
.help(ISO_8601_HELP_STRING),
)
.arg(
Arg::with_name(OPT_RFC_EMAIL)
.short("R")
Arg::new(OPT_RFC_EMAIL)
.short('R')
.long(OPT_RFC_EMAIL)
.help(RFC_5322_HELP_STRING),
)
.arg(
Arg::with_name(OPT_RFC_3339)
Arg::new(OPT_RFC_3339)
.long(OPT_RFC_3339)
.takes_value(true)
.help(RFC_3339_HELP_STRING),
)
.arg(
Arg::with_name(OPT_DEBUG)
Arg::new(OPT_DEBUG)
.long(OPT_DEBUG)
.help("annotate the parsed date, and warn about questionable usage to stderr"),
)
.arg(
Arg::with_name(OPT_REFERENCE)
.short("r")
Arg::new(OPT_REFERENCE)
.short('r')
.long(OPT_REFERENCE)
.takes_value(true)
.help("display the last modification time of FILE"),
)
.arg(
Arg::with_name(OPT_SET)
.short("s")
Arg::new(OPT_SET)
.short('s')
.long(OPT_SET)
.takes_value(true)
.help(OPT_SET_HELP_STRING),
)
.arg(
Arg::with_name(OPT_UNIVERSAL)
.short("u")
Arg::new(OPT_UNIVERSAL)
.short('u')
.long(OPT_UNIVERSAL)
.alias(OPT_UNIVERSAL_2)
.help("print or set Coordinated Universal Time (UTC)"),
)
.arg(Arg::with_name(OPT_FORMAT).multiple(false))
.arg(Arg::new(OPT_FORMAT).multiple_occurrences(false))
}
/// Return the appropriate format string for the given settings.

View file

@ -1,6 +1,6 @@
[package]
name = "uu_dd"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "dd ~ (uutils) copy and convert files"
@ -16,7 +16,7 @@ path = "src/dd.rs"
[dependencies]
byte-unit = "4.0"
clap = { version = "2.33", features = [ "wrap_help" ] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
gcd = "2.0"
libc = "0.2"
uucore = { version=">=0.0.8", package="uucore", path="../../uucore" }

View file

@ -36,7 +36,7 @@ use std::thread;
use std::time;
use byte_unit::Byte;
use clap::{self, crate_version};
use clap::{crate_version, App, Arg, ArgMatches};
use gcd::Gcd;
#[cfg(target_os = "linux")]
use signal_hook::consts::signal;
@ -932,12 +932,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app() -> clap::App<'static, 'static> {
clap::App::new(uucore::util_name())
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
clap::Arg::with_name(options::INFILE)
Arg::new(options::INFILE)
.long(options::INFILE)
.takes_value(true)
.require_equals(true)
@ -945,7 +945,7 @@ pub fn uu_app() -> clap::App<'static, 'static> {
.help("(alternatively if=FILE) specifies the file used for input. When not specified, stdin is used instead")
)
.arg(
clap::Arg::with_name(options::OUTFILE)
Arg::new(options::OUTFILE)
.long(options::OUTFILE)
.takes_value(true)
.require_equals(true)
@ -953,7 +953,7 @@ pub fn uu_app() -> clap::App<'static, 'static> {
.help("(alternatively of=FILE) specifies the file used for output. When not specified, stdout is used instead")
)
.arg(
clap::Arg::with_name(options::IBS)
Arg::new(options::IBS)
.long(options::IBS)
.takes_value(true)
.require_equals(true)
@ -961,7 +961,7 @@ pub fn uu_app() -> clap::App<'static, 'static> {
.help("(alternatively ibs=N) specifies the size of buffer used for reads (default: 512). Multiplier strings permitted.")
)
.arg(
clap::Arg::with_name(options::OBS)
Arg::new(options::OBS)
.long(options::OBS)
.takes_value(true)
.require_equals(true)
@ -969,7 +969,7 @@ pub fn uu_app() -> clap::App<'static, 'static> {
.help("(alternatively obs=N) specifies the size of buffer used for writes (default: 512). Multiplier strings permitted.")
)
.arg(
clap::Arg::with_name(options::BS)
Arg::new(options::BS)
.long(options::BS)
.takes_value(true)
.require_equals(true)
@ -977,7 +977,7 @@ pub fn uu_app() -> clap::App<'static, 'static> {
.help("(alternatively bs=N) specifies ibs=N and obs=N (default: 512). If ibs or obs are also specified, bs=N takes precedence. Multiplier strings permitted.")
)
.arg(
clap::Arg::with_name(options::CBS)
Arg::new(options::CBS)
.long(options::CBS)
.takes_value(true)
.require_equals(true)
@ -985,7 +985,7 @@ pub fn uu_app() -> clap::App<'static, 'static> {
.help("(alternatively cbs=BYTES) specifies the 'conversion block size' in bytes. Applies to the conv=block, and conv=unblock operations. Multiplier strings permitted.")
)
.arg(
clap::Arg::with_name(options::SKIP)
Arg::new(options::SKIP)
.long(options::SKIP)
.takes_value(true)
.require_equals(true)
@ -993,7 +993,7 @@ pub fn uu_app() -> clap::App<'static, 'static> {
.help("(alternatively skip=N) causes N ibs-sized records of input to be skipped before beginning copy/convert operations. See iflag=count_bytes if skipping N bytes is preferred. Multiplier strings permitted.")
)
.arg(
clap::Arg::with_name(options::SEEK)
Arg::new(options::SEEK)
.long(options::SEEK)
.takes_value(true)
.require_equals(true)
@ -1001,7 +1001,7 @@ pub fn uu_app() -> clap::App<'static, 'static> {
.help("(alternatively seek=N) seeks N obs-sized records into output before beginning copy/convert operations. See oflag=seek_bytes if seeking N bytes is preferred. Multiplier strings permitted.")
)
.arg(
clap::Arg::with_name(options::COUNT)
Arg::new(options::COUNT)
.long(options::COUNT)
.takes_value(true)
.require_equals(true)
@ -1009,7 +1009,7 @@ pub fn uu_app() -> clap::App<'static, 'static> {
.help("(alternatively count=N) stop reading input after N ibs-sized read operations rather than proceeding until EOF. See iflag=count_bytes if stopping after N bytes is preferred. Multiplier strings permitted.")
)
.arg(
clap::Arg::with_name(options::STATUS)
Arg::new(options::STATUS)
.long(options::STATUS)
.takes_value(true)
.require_equals(true)
@ -1033,7 +1033,7 @@ Printing performance stats is also triggered by the INFO signal (where supported
")
)
.arg(
clap::Arg::with_name(options::CONV)
Arg::new(options::CONV)
.long(options::CONV)
.takes_value(true)
.require_equals(true)
@ -1070,7 +1070,7 @@ Conversion Flags:
")
)
.arg(
clap::Arg::with_name(options::IFLAG)
Arg::new(options::IFLAG)
.long(options::IFLAG)
.takes_value(true)
.require_equals(true)
@ -1096,7 +1096,7 @@ General-Flags
")
)
.arg(
clap::Arg::with_name(options::OFLAG)
Arg::new(options::OFLAG)
.long(options::OFLAG)
.takes_value(true)
.require_equals(true)

View file

@ -311,6 +311,6 @@ fn test_nocreat_causes_failure_when_ofile_doesnt_exist() {
String::from("--of=not-a-real.file"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let _ = Output::<File>::new(&matches).unwrap();
}

View file

@ -13,7 +13,7 @@ use super::*;
use std::error::Error;
use uucore::error::UError;
pub type Matches = clap::ArgMatches<'static>;
pub type Matches = ArgMatches;
/// Parser Errors describe errors with parser input
#[derive(Debug, PartialEq)]

View file

@ -25,7 +25,7 @@ fn unimplemented_flags_should_error_non_linux() {
format!("--iflag={}", flag),
format!("--oflag={}", flag),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
if parse_iflags(&matches).is_ok() {
succeeded.push(format!("iflag={}", flag));
@ -53,7 +53,7 @@ fn unimplemented_flags_should_error() {
format!("--iflag={}", flag),
format!("--oflag={}", flag),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
if parse_iflags(&matches).is_ok() {
succeeded.push(format!("iflag={}", flag))
@ -78,7 +78,7 @@ fn test_status_level_absent() {
String::from("--of=bar.file"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let st = parse_status_level(&matches).unwrap();
assert_eq!(st, None);
@ -93,7 +93,7 @@ fn test_status_level_none() {
String::from("--of=bar.file"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let st = parse_status_level(&matches).unwrap().unwrap();
assert_eq!(st, StatusLevel::None);
@ -121,7 +121,7 @@ fn test_all_top_level_args_no_leading_dashes() {
.into_iter()
.fold(Vec::new(), append_dashes_if_not_present);
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
assert_eq!(100, parse_ibs(&matches).unwrap());
assert_eq!(100, parse_obs(&matches).unwrap());
@ -205,7 +205,7 @@ fn test_all_top_level_args_with_leading_dashes() {
.into_iter()
.fold(Vec::new(), append_dashes_if_not_present);
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
assert_eq!(100, parse_ibs(&matches).unwrap());
assert_eq!(100, parse_obs(&matches).unwrap());
@ -276,7 +276,7 @@ fn test_status_level_progress() {
String::from("--status=progress"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let st = parse_status_level(&matches).unwrap().unwrap();
assert_eq!(st, StatusLevel::Progress);
@ -291,7 +291,7 @@ fn test_status_level_noxfer() {
String::from("--of=bar.file"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let st = parse_status_level(&matches).unwrap().unwrap();
assert_eq!(st, StatusLevel::Noxfer);
@ -304,7 +304,7 @@ fn test_status_level_noxfer() {
fn icf_ctable_error() {
let args = vec![String::from("dd"), String::from("--conv=ascii,ebcdic,ibm")];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let _ = parse_conv_flag_input(&matches).unwrap();
}
@ -314,7 +314,7 @@ fn icf_ctable_error() {
fn icf_case_error() {
let args = vec![String::from("dd"), String::from("--conv=ucase,lcase")];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let _ = parse_conv_flag_input(&matches).unwrap();
}
@ -324,7 +324,7 @@ fn icf_case_error() {
fn icf_block_error() {
let args = vec![String::from("dd"), String::from("--conv=block,unblock")];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let _ = parse_conv_flag_input(&matches).unwrap();
}
@ -334,7 +334,7 @@ fn icf_block_error() {
fn icf_creat_error() {
let args = vec![String::from("dd"), String::from("--conv=excl,nocreat")];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let _ = parse_conv_flag_output(&matches).unwrap();
}
@ -344,7 +344,7 @@ fn parse_icf_token_ibm() {
let exp = vec![ConvFlag::FmtAtoI];
let args = vec![String::from("dd"), String::from("--conv=ibm")];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let act = parse_flag_list::<ConvFlag>("conv", &matches).unwrap();
@ -362,7 +362,7 @@ fn parse_icf_tokens_elu() {
String::from("dd"),
String::from("--conv=ebcdic,lcase,unblock"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let act = parse_flag_list::<ConvFlag>("conv", &matches).unwrap();
assert_eq!(exp.len(), act.len());
@ -393,7 +393,7 @@ fn parse_icf_tokens_remaining() {
String::from("dd"),
String::from("--conv=ascii,ucase,block,sparse,swab,sync,noerror,excl,nocreat,notrunc,noerror,fdatasync,fsync"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let act = parse_flag_list::<ConvFlag>("conv", &matches).unwrap();
@ -417,7 +417,7 @@ fn parse_iflag_tokens() {
String::from("dd"),
String::from("--iflag=fullblock,count_bytes,skip_bytes,append,seek_bytes"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let act = parse_flag_list::<Flag>("iflag", &matches).unwrap();
@ -441,7 +441,7 @@ fn parse_oflag_tokens() {
String::from("dd"),
String::from("--oflag=fullblock,count_bytes,skip_bytes,append,seek_bytes"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let act = parse_flag_list::<Flag>("oflag", &matches).unwrap();
@ -469,7 +469,7 @@ fn parse_iflag_tokens_linux() {
String::from("dd"),
String::from("--iflag=direct,directory,dsync,sync,nonblock,noatime,noctty,nofollow"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let act = parse_flag_list::<Flag>("iflag", &matches).unwrap();
@ -497,7 +497,7 @@ fn parse_oflag_tokens_linux() {
String::from("dd"),
String::from("--oflag=direct,directory,dsync,sync,nonblock,noatime,noctty,nofollow"),
];
let matches = uu_app().get_matches_from_safe(args).unwrap();
let matches = uu_app().try_get_matches_from(args).unwrap();
let act = parse_flag_list::<Flag>("oflag", &matches).unwrap();

View file

@ -1,6 +1,6 @@
[package]
name = "uu_df"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "df ~ (uutils) display file system information"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/df.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
number_prefix = "0.4"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc", "fsext"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -280,7 +280,7 @@ impl UError for DfError {
#[uucore_procs::gen_uumain]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let paths: Vec<String> = matches
.values_of(OPT_PATHS)
@ -421,19 +421,19 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(OPT_ALL)
.short("a")
Arg::new(OPT_ALL)
.short('a')
.long("all")
.help("include dummy file systems"),
)
.arg(
Arg::with_name(OPT_BLOCKSIZE)
.short("B")
Arg::new(OPT_BLOCKSIZE)
.short('B')
.long("block-size")
.takes_value(true)
.help(
@ -442,54 +442,50 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(OPT_DIRECT)
Arg::new(OPT_DIRECT)
.long("direct")
.help("show statistics for a file instead of mount point"),
)
.arg(
Arg::with_name(OPT_TOTAL)
Arg::new(OPT_TOTAL)
.long("total")
.help("produce a grand total"),
)
.arg(
Arg::with_name(OPT_HUMAN_READABLE)
.short("h")
Arg::new(OPT_HUMAN_READABLE)
.short('h')
.long("human-readable")
.conflicts_with(OPT_HUMAN_READABLE_2)
.help("print sizes in human readable format (e.g., 1K 234M 2G)"),
)
.arg(
Arg::with_name(OPT_HUMAN_READABLE_2)
.short("H")
Arg::new(OPT_HUMAN_READABLE_2)
.short('H')
.long("si")
.conflicts_with(OPT_HUMAN_READABLE)
.help("likewise, but use powers of 1000 not 1024"),
)
.arg(
Arg::with_name(OPT_INODES)
.short("i")
Arg::new(OPT_INODES)
.short('i')
.long("inodes")
.help("list inode information instead of block usage"),
)
.arg(Arg::new(OPT_KILO).short('k').help("like --block-size=1K"))
.arg(
Arg::with_name(OPT_KILO)
.short("k")
.help("like --block-size=1K"),
)
.arg(
Arg::with_name(OPT_LOCAL)
.short("l")
Arg::new(OPT_LOCAL)
.short('l')
.long("local")
.help("limit listing to local file systems"),
)
.arg(
Arg::with_name(OPT_NO_SYNC)
Arg::new(OPT_NO_SYNC)
.long("no-sync")
.conflicts_with(OPT_SYNC)
.help("do not invoke sync before getting usage info (default)"),
)
.arg(
Arg::with_name(OPT_OUTPUT)
Arg::new(OPT_OUTPUT)
.long("output")
.takes_value(true)
.use_delimiter(true)
@ -499,39 +495,40 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(OPT_PORTABILITY)
.short("P")
Arg::new(OPT_PORTABILITY)
.short('P')
.long("portability")
.help("use the POSIX output format"),
)
.arg(
Arg::with_name(OPT_SYNC)
Arg::new(OPT_SYNC)
.long("sync")
.conflicts_with(OPT_NO_SYNC)
.help("invoke sync before getting usage info"),
)
.arg(
Arg::with_name(OPT_TYPE)
.short("t")
Arg::new(OPT_TYPE)
.short('t')
.long("type")
.allow_invalid_utf8(true)
.takes_value(true)
.use_delimiter(true)
.help("limit listing to file systems of type TYPE"),
)
.arg(
Arg::with_name(OPT_PRINT_TYPE)
.short("T")
Arg::new(OPT_PRINT_TYPE)
.short('T')
.long("print-type")
.help("print file system type"),
)
.arg(
Arg::with_name(OPT_EXCLUDE_TYPE)
.short("x")
Arg::new(OPT_EXCLUDE_TYPE)
.short('x')
.long("exclude-type")
.takes_value(true)
.use_delimiter(true)
.help("limit listing to file systems not of type TYPE"),
)
.arg(Arg::with_name(OPT_PATHS).multiple(true))
.help("Filesystem(s) to list")
.arg(Arg::new(OPT_PATHS).multiple_occurrences(true))
.override_help("Filesystem(s) to list")
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_dircolors"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "dircolors ~ (uutils) display commands to set LS_COLORS"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/dircolors.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
glob = "0.3.0"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -73,7 +73,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(&args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(&args);
let files = matches
.values_of(options::FILE)
@ -160,35 +160,39 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(SUMMARY)
.after_help(LONG_HELP)
.arg(
Arg::with_name(options::BOURNE_SHELL)
Arg::new(options::BOURNE_SHELL)
.long("sh")
.short("b")
.short('b')
.visible_alias("bourne-shell")
.help("output Bourne shell code to set LS_COLORS")
.display_order(1),
)
.arg(
Arg::with_name(options::C_SHELL)
Arg::new(options::C_SHELL)
.long("csh")
.short("c")
.short('c')
.visible_alias("c-shell")
.help("output C shell code to set LS_COLORS")
.display_order(2),
)
.arg(
Arg::with_name(options::PRINT_DATABASE)
Arg::new(options::PRINT_DATABASE)
.long("print-database")
.short("p")
.short('p')
.help("print the byte counts")
.display_order(3),
)
.arg(Arg::with_name(options::FILE).hidden(true).multiple(true))
.arg(
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true),
)
}
pub trait StrUtils {

View file

@ -1,6 +1,6 @@
[package]
name = "uu_dirname"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "dirname ~ (uutils) display parent directory of PATHNAME"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/dirname.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -39,7 +39,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let after_help = get_long_usage();
let matches = uu_app()
.usage(&usage[..])
.override_usage(&usage[..])
.after_help(&after_help[..])
.get_matches_from(args);
@ -83,15 +83,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.about(ABOUT)
.version(crate_version!())
.arg(
Arg::with_name(options::ZERO)
Arg::new(options::ZERO)
.long(options::ZERO)
.short("z")
.short('z')
.help("separate output with NUL rather than newline"),
)
.arg(Arg::with_name(options::DIR).hidden(true).multiple(true))
.arg(Arg::new(options::DIR).hide(true).multiple_occurrences(true))
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_du"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "du ~ (uutils) display disk usage"
@ -15,8 +15,8 @@ edition = "2018"
path = "src/du.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
chrono = "^0.4.11"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -462,7 +462,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let summarize = matches.is_present(options::SUMMARIZE);
@ -625,19 +625,19 @@ fn parse_depth(max_depth_str: Option<&str>, summarize: bool) -> UResult<Option<u
}
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(SUMMARY)
.after_help(LONG_HELP)
.arg(
Arg::with_name(options::ALL)
.short("a")
Arg::new(options::ALL)
.short('a')
.long(options::ALL)
.help("write counts for all files, not just directories"),
)
.arg(
Arg::with_name(options::APPARENT_SIZE)
Arg::new(options::APPARENT_SIZE)
.long(options::APPARENT_SIZE)
.help(
"print apparent sizes, rather than disk usage \
@ -647,8 +647,8 @@ pub fn uu_app() -> App<'static, 'static> {
.alias("app") // The GNU test suite uses this alias
)
.arg(
Arg::with_name(options::BLOCK_SIZE)
.short("B")
Arg::new(options::BLOCK_SIZE)
.short('B')
.long(options::BLOCK_SIZE)
.value_name("SIZE")
.help(
@ -657,20 +657,20 @@ pub fn uu_app() -> App<'static, 'static> {
)
)
.arg(
Arg::with_name(options::BYTES)
.short("b")
Arg::new(options::BYTES)
.short('b')
.long("bytes")
.help("equivalent to '--apparent-size --block-size=1'")
)
.arg(
Arg::with_name(options::TOTAL)
Arg::new(options::TOTAL)
.long("total")
.short("c")
.short('c')
.help("produce a grand total")
)
.arg(
Arg::with_name(options::MAX_DEPTH)
.short("d")
Arg::new(options::MAX_DEPTH)
.short('d')
.long("max-depth")
.value_name("N")
.help(
@ -680,78 +680,78 @@ pub fn uu_app() -> App<'static, 'static> {
)
)
.arg(
Arg::with_name(options::HUMAN_READABLE)
Arg::new(options::HUMAN_READABLE)
.long("human-readable")
.short("h")
.short('h')
.help("print sizes in human readable format (e.g., 1K 234M 2G)")
)
.arg(
Arg::with_name(options::INODES)
Arg::new(options::INODES)
.long(options::INODES)
.help(
"list inode usage information instead of block usage like --block-size=1K"
)
)
.arg(
Arg::with_name(options::BLOCK_SIZE_1K)
.short("k")
Arg::new(options::BLOCK_SIZE_1K)
.short('k')
.help("like --block-size=1K")
)
.arg(
Arg::with_name(options::COUNT_LINKS)
.short("l")
Arg::new(options::COUNT_LINKS)
.short('l')
.long("count-links")
.help("count sizes many times if hard linked")
)
.arg(
Arg::with_name(options::DEREFERENCE)
.short("L")
Arg::new(options::DEREFERENCE)
.short('L')
.long(options::DEREFERENCE)
.help("dereference all symbolic links")
)
// .arg(
// Arg::with_name("no-dereference")
// .short("P")
// Arg::new("no-dereference")
// .short('P')
// .long("no-dereference")
// .help("don't follow any symbolic links (this is the default)")
// )
.arg(
Arg::with_name(options::BLOCK_SIZE_1M)
.short("m")
Arg::new(options::BLOCK_SIZE_1M)
.short('m')
.help("like --block-size=1M")
)
.arg(
Arg::with_name(options::NULL)
.short("0")
Arg::new(options::NULL)
.short('0')
.long("null")
.help("end each output line with 0 byte rather than newline")
)
.arg(
Arg::with_name(options::SEPARATE_DIRS)
.short("S")
Arg::new(options::SEPARATE_DIRS)
.short('S')
.long("separate-dirs")
.help("do not include size of subdirectories")
)
.arg(
Arg::with_name(options::SUMMARIZE)
.short("s")
Arg::new(options::SUMMARIZE)
.short('s')
.long("summarize")
.help("display only a total for each argument")
)
.arg(
Arg::with_name(options::SI)
Arg::new(options::SI)
.long(options::SI)
.help("like -h, but use powers of 1000 not 1024")
)
.arg(
Arg::with_name(options::ONE_FILE_SYSTEM)
.short("x")
Arg::new(options::ONE_FILE_SYSTEM)
.short('x')
.long(options::ONE_FILE_SYSTEM)
.help("skip directories on different file systems")
)
.arg(
Arg::with_name(options::THRESHOLD)
.short("t")
Arg::new(options::THRESHOLD)
.short('t')
.long(options::THRESHOLD)
.alias("th")
.value_name("SIZE")
@ -761,20 +761,20 @@ pub fn uu_app() -> App<'static, 'static> {
or entries greater than SIZE if negative")
)
// .arg(
// Arg::with_name("")
// .short("x")
// Arg::new("")
// .short('x')
// .long("exclude-from")
// .value_name("FILE")
// .help("exclude files that match any pattern in FILE")
// )
// .arg(
// Arg::with_name("exclude")
// Arg::new("exclude")
// .long("exclude")
// .value_name("PATTERN")
// .help("exclude files that match PATTERN")
// )
.arg(
Arg::with_name(options::TIME)
Arg::new(options::TIME)
.long(options::TIME)
.value_name("WORD")
.require_equals(true)
@ -787,7 +787,7 @@ pub fn uu_app() -> App<'static, 'static> {
)
)
.arg(
Arg::with_name(options::TIME_STYLE)
Arg::new(options::TIME_STYLE)
.long(options::TIME_STYLE)
.value_name("STYLE")
.help(
@ -796,9 +796,9 @@ pub fn uu_app() -> App<'static, 'static> {
)
)
.arg(
Arg::with_name(options::FILE)
.hidden(true)
.multiple(true)
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true)
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_echo"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "echo ~ (uutils) display TEXT"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/echo.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -128,44 +128,37 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
execute(no_newline, escaped, values).map_err_context(|| "could not write to stdout".to_string())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.name(NAME)
// TrailingVarArg specifies the final positional argument is a VarArg
// and it doesn't attempts the parse any further args.
// Final argument must have multiple(true) or the usage string equivalent.
.setting(clap::AppSettings::TrailingVarArg)
.setting(clap::AppSettings::AllowLeadingHyphen)
.setting(clap::AppSettings::AllowHyphenValues)
.version(crate_version!())
.about(SUMMARY)
.after_help(AFTER_HELP)
.usage(USAGE)
.override_usage(USAGE)
.arg(
Arg::with_name(options::NO_NEWLINE)
.short("n")
Arg::new(options::NO_NEWLINE)
.short('n')
.help("do not output the trailing newline")
.takes_value(false)
.display_order(1),
.takes_value(false),
)
.arg(
Arg::with_name(options::ENABLE_BACKSLASH_ESCAPE)
.short("e")
Arg::new(options::ENABLE_BACKSLASH_ESCAPE)
.short('e')
.help("enable interpretation of backslash escapes")
.takes_value(false)
.display_order(2),
.takes_value(false),
)
.arg(
Arg::with_name(options::DISABLE_BACKSLASH_ESCAPE)
.short("E")
Arg::new(options::DISABLE_BACKSLASH_ESCAPE)
.short('E')
.help("disable interpretation of backslash escapes (default)")
.takes_value(false)
.display_order(3),
)
.arg(
Arg::with_name(options::STRING)
.multiple(true)
.allow_hyphen_values(true),
.takes_value(false),
)
.arg(Arg::new(options::STRING).multiple_occurrences(true))
}
fn execute(no_newline: bool, escaped: bool, free: Vec<String>) -> io::Result<()> {

View file

@ -1,6 +1,6 @@
[package]
name = "uu_env"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "env ~ (uutils) set each NAME to VALUE in the environment and run COMMAND"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/env.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
rust-ini = "0.17.0"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }

30
src/uu/env/src/env.rs vendored
View file

@ -119,46 +119,46 @@ fn build_command<'a, 'b>(args: &'a mut Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b
(progname, &args[..])
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(crate_name!())
.version(crate_version!())
.author(crate_authors!())
.about(crate_description!())
.usage(USAGE)
.override_usage(USAGE)
.after_help(AFTER_HELP)
.setting(AppSettings::AllowExternalSubcommands)
.arg(Arg::with_name("ignore-environment")
.short("i")
.arg(Arg::new("ignore-environment")
.short('i')
.long("ignore-environment")
.help("start with an empty environment"))
.arg(Arg::with_name("chdir")
.short("C") // GNU env compatibility
.arg(Arg::new("chdir")
.short('C') // GNU env compatibility
.long("chdir")
.takes_value(true)
.number_of_values(1)
.value_name("DIR")
.help("change working directory to DIR"))
.arg(Arg::with_name("null")
.short("0")
.arg(Arg::new("null")
.short('0')
.long("null")
.help("end each output line with a 0 byte rather than a newline (only valid when \
printing the environment)"))
.arg(Arg::with_name("file")
.short("f")
.arg(Arg::new("file")
.short('f')
.long("file")
.takes_value(true)
.number_of_values(1)
.value_name("PATH")
.multiple(true)
.multiple_occurrences(true)
.help("read and set variables from a \".env\"-style configuration file (prior to any \
unset and/or set)"))
.arg(Arg::with_name("unset")
.short("u")
.arg(Arg::new("unset")
.short('u')
.long("unset")
.takes_value(true)
.number_of_values(1)
.value_name("NAME")
.multiple(true)
.multiple_occurrences(true)
.help("remove variable from the environment"))
}
@ -203,7 +203,7 @@ fn run_env(args: impl uucore::Args) -> UResult<()> {
// we handle the name, value pairs and the program to be executed by treating them as external
// subcommands in clap
if let (external, Some(matches)) = matches.subcommand() {
if let Some((external, matches)) = matches.subcommand() {
let mut begin_prog_opts = false;
if external == "-" {

View file

@ -1,6 +1,6 @@
[package]
name = "uu_expand"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "expand ~ (uutils) convert input tabs to spaces"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/expand.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
unicode-width = "0.1.5"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -174,39 +174,39 @@ impl Options {
#[uucore_procs::gen_uumain]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
expand(Options::new(&matches)).map_err_context(|| "failed to write output".to_string())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.after_help(LONG_HELP)
.arg(
Arg::with_name(options::INITIAL)
Arg::new(options::INITIAL)
.long(options::INITIAL)
.short("i")
.short('i')
.help("do not convert tabs after non blanks"),
)
.arg(
Arg::with_name(options::TABS)
Arg::new(options::TABS)
.long(options::TABS)
.short("t")
.short('t')
.value_name("N, LIST")
.takes_value(true)
.help("have tabs N characters apart, not 8 or use comma separated list of explicit tab positions"),
)
.arg(
Arg::with_name(options::NO_UTF8)
Arg::new(options::NO_UTF8)
.long(options::NO_UTF8)
.short("U")
.short('U')
.help("interpret input file as 8-bit ASCII rather than UTF-8"),
).arg(
Arg::with_name(options::FILES)
.multiple(true)
.hidden(true)
Arg::new(options::FILES)
.multiple_occurrences(true)
.hide(true)
.takes_value(true)
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_expr"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "expr ~ (uutils) display the value of EXPRESSION"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/expr.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
num-bigint = "0.4.0"
num-traits = "0.2.14"

View file

@ -15,10 +15,10 @@ mod tokens;
const VERSION: &str = "version";
const HELP: &str = "help";
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.arg(Arg::with_name(VERSION).long(VERSION))
.arg(Arg::with_name(HELP).long(HELP))
.arg(Arg::new(VERSION).long(VERSION))
.arg(Arg::new(HELP).long(HELP))
}
#[uucore_procs::gen_uumain]

View file

@ -1,6 +1,6 @@
[package]
name = "uu_factor"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "factor ~ (uutils) display the prime factors of each NUMBER"
@ -15,7 +15,7 @@ edition = "2018"
num-traits = "0.2.13" # used in src/numerics.rs, which is included by build.rs
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
coz = { version = "0.1.3", optional = true }
num-traits = "0.2.13" # Needs at least version 0.2.13 for "OverflowingAdd"
rand = { version = "0.7", features = ["small_rng"] }

View file

@ -77,9 +77,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(SUMMARY)
.arg(Arg::with_name(options::NUMBER).multiple(true))
.arg(Arg::new(options::NUMBER).multiple_occurrences(true))
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_false"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "false ~ (uutils) do nothing and fail"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/false.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -14,6 +14,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Err(1.into())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_fmt"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "fmt ~ (uutils) reformat each paragraph of input"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/fmt.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
unicode-width = "0.1.5"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }

View file

@ -71,7 +71,7 @@ pub struct FmtOptions {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let mut files: Vec<String> = matches
.values_of(ARG_FILES)
@ -222,13 +222,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(OPT_CROWN_MARGIN)
.short("c")
Arg::new(OPT_CROWN_MARGIN)
.short('c')
.long(OPT_CROWN_MARGIN)
.help(
"First and second line of paragraph \
@ -238,8 +238,8 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(OPT_TAGGED_PARAGRAPH)
.short("t")
Arg::new(OPT_TAGGED_PARAGRAPH)
.short('t')
.long("tagged-paragraph")
.help(
"Like -c, except that the first and second line of a paragraph *must* \
@ -247,8 +247,8 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(OPT_PRESERVE_HEADERS)
.short("m")
Arg::new(OPT_PRESERVE_HEADERS)
.short('m')
.long("preserve-headers")
.help(
"Attempt to detect and preserve mail headers in the input. \
@ -256,14 +256,14 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(OPT_SPLIT_ONLY)
.short("s")
Arg::new(OPT_SPLIT_ONLY)
.short('s')
.long("split-only")
.help("Split lines only, do not reflow."),
)
.arg(
Arg::with_name(OPT_UNIFORM_SPACING)
.short("u")
Arg::new(OPT_UNIFORM_SPACING)
.short('u')
.long("uniform-spacing")
.help(
"Insert exactly one \
@ -274,8 +274,8 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(OPT_PREFIX)
.short("p")
Arg::new(OPT_PREFIX)
.short('p')
.long("prefix")
.help(
"Reformat only lines \
@ -286,8 +286,8 @@ pub fn uu_app() -> App<'static, 'static> {
.value_name("PREFIX"),
)
.arg(
Arg::with_name(OPT_SKIP_PREFIX)
.short("P")
Arg::new(OPT_SKIP_PREFIX)
.short('P')
.long("skip-prefix")
.help(
"Do not reformat lines \
@ -297,8 +297,8 @@ pub fn uu_app() -> App<'static, 'static> {
.value_name("PSKIP"),
)
.arg(
Arg::with_name(OPT_EXACT_PREFIX)
.short("x")
Arg::new(OPT_EXACT_PREFIX)
.short('x')
.long("exact-prefix")
.help(
"PREFIX must match at the \
@ -306,8 +306,8 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(OPT_EXACT_SKIP_PREFIX)
.short("X")
Arg::new(OPT_EXACT_SKIP_PREFIX)
.short('X')
.long("exact-skip-prefix")
.help(
"PSKIP must match at the \
@ -315,26 +315,26 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(OPT_WIDTH)
.short("w")
Arg::new(OPT_WIDTH)
.short('w')
.long("width")
.help("Fill output lines up to a maximum of WIDTH columns, default 79.")
.value_name("WIDTH"),
)
.arg(
Arg::with_name(OPT_GOAL)
.short("g")
Arg::new(OPT_GOAL)
.short('g')
.long("goal")
.help("Goal width, default ~0.94*WIDTH. Must be less than WIDTH.")
.value_name("GOAL"),
)
.arg(Arg::with_name(OPT_QUICK).short("q").long("quick").help(
.arg(Arg::new(OPT_QUICK).short('q').long("quick").help(
"Break lines more quickly at the \
expense of a potentially more ragged appearance.",
))
.arg(
Arg::with_name(OPT_TAB_WIDTH)
.short("T")
Arg::new(OPT_TAB_WIDTH)
.short('T')
.long("tab-width")
.help(
"Treat tabs as TABWIDTH spaces for \
@ -343,5 +343,9 @@ pub fn uu_app() -> App<'static, 'static> {
)
.value_name("TABWIDTH"),
)
.arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true))
.arg(
Arg::new(ARG_FILES)
.multiple_occurrences(true)
.takes_value(true),
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_fold"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "fold ~ (uutils) wrap each line of input"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/fold.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -63,16 +63,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
fold(files, bytes, spaces, width)
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.name(NAME)
.version(crate_version!())
.usage(SYNTAX)
.override_usage(SYNTAX)
.about(SUMMARY)
.arg(
Arg::with_name(options::BYTES)
Arg::new(options::BYTES)
.long(options::BYTES)
.short("b")
.short('b')
.help(
"count using bytes rather than columns (meaning control characters \
such as newline are not treated specially)",
@ -80,22 +80,26 @@ pub fn uu_app() -> App<'static, 'static> {
.takes_value(false),
)
.arg(
Arg::with_name(options::SPACES)
Arg::new(options::SPACES)
.long(options::SPACES)
.short("s")
.short('s')
.help("break lines at word boundaries rather than a hard cut-off")
.takes_value(false),
)
.arg(
Arg::with_name(options::WIDTH)
Arg::new(options::WIDTH)
.long(options::WIDTH)
.short("w")
.short('w')
.help("set WIDTH as the maximum line width rather than 80")
.value_name("WIDTH")
.allow_hyphen_values(true)
.takes_value(true),
)
.arg(Arg::with_name(options::FILE).hidden(true).multiple(true))
.arg(
Arg::new(options::FILE)
.hide(true)
.multiple_occurrences(true),
)
}
fn handle_obsolete(args: &[String]) -> (Vec<String>, Option<String>) {

View file

@ -1,6 +1,6 @@
[package]
name = "uu_groups"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "groups ~ (uutils) display group memberships for USERNAME"
@ -15,9 +15,9 @@ edition = "2018"
path = "src/groups.rs"
[dependencies]
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "process"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
clap = { version = "2.33", features = ["wrap_help"] }
[[bin]]
name = "groups"

View file

@ -73,7 +73,7 @@ fn infallible_gid2grp(gid: &u32) -> String {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let users: Vec<String> = matches
.values_of(options::USERS)
@ -105,13 +105,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(options::USERS)
.multiple(true)
Arg::new(options::USERS)
.multiple_occurrences(true)
.takes_value(true)
.value_name(options::USERS),
)

View file

@ -1,6 +1,6 @@
[package]
name = "uu_hashsum"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "hashsum ~ (uutils) display or check input digests"
@ -16,7 +16,7 @@ path = "src/hashsum.rs"
[dependencies]
digest = "0.6.1"
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
hex = "0.2.0"
libc = "0.2.42"
memchr = "2"

View file

@ -74,9 +74,9 @@ fn is_custom_binary(program: &str) -> bool {
}
#[allow(clippy::cognitive_complexity)]
fn detect_algo<'a>(
fn detect_algo(
program: &str,
matches: &ArgMatches<'a>,
matches: &ArgMatches,
) -> (&'static str, Box<dyn Digest + 'static>, usize) {
let mut alg: Option<Box<dyn Digest>> = None;
let mut name: &'static str = "";
@ -270,10 +270,8 @@ fn parse_bit_num(arg: &str) -> Result<usize, ParseIntError> {
arg.parse()
}
fn is_valid_bit_num(arg: String) -> Result<(), String> {
parse_bit_num(&arg)
.map(|_| ())
.map_err(|e| format!("{}", e))
fn is_valid_bit_num(arg: &str) -> Result<(), String> {
parse_bit_num(arg).map(|_| ()).map_err(|e| format!("{}", e))
}
#[uucore_procs::gen_uumain]
@ -292,7 +290,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
let app = uu_app(&binary_name);
// FIXME: this should use get_matches_from_safe() and crash!(), but at the moment that just
// FIXME: this should use try_get_matches_from() and crash!(), but at the moment that just
// causes "error: " to be printed twice (once from crash!() and once from clap). With
// the current setup, the name of the utility is not printed, but I think this is at
// least somewhat better from a user's perspective.
@ -333,7 +331,7 @@ pub fn uumain(mut args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app_common() -> App<'static, 'static> {
pub fn uu_app_common<'a>() -> App<'a> {
#[cfg(windows)]
const BINARY_HELP: &str = "read in binary mode (default)";
#[cfg(not(windows))]
@ -346,55 +344,55 @@ pub fn uu_app_common() -> App<'static, 'static> {
.version(crate_version!())
.about("Compute and check message digests.")
.arg(
Arg::with_name("binary")
.short("b")
Arg::new("binary")
.short('b')
.long("binary")
.help(BINARY_HELP),
)
.arg(
Arg::with_name("check")
.short("c")
Arg::new("check")
.short('c')
.long("check")
.help("read hashsums from the FILEs and check them"),
)
.arg(
Arg::with_name("tag")
Arg::new("tag")
.long("tag")
.help("create a BSD-style checksum"),
)
.arg(
Arg::with_name("text")
.short("t")
Arg::new("text")
.short('t')
.long("text")
.help(TEXT_HELP)
.conflicts_with("binary"),
)
.arg(
Arg::with_name("quiet")
.short("q")
Arg::new("quiet")
.short('q')
.long("quiet")
.help("don't print OK for each successfully verified file"),
)
.arg(
Arg::with_name("status")
.short("s")
Arg::new("status")
.short('s')
.long("status")
.help("don't output anything, status code shows success"),
)
.arg(
Arg::with_name("strict")
Arg::new("strict")
.long("strict")
.help("exit non-zero for improperly formatted checksum lines"),
)
.arg(
Arg::with_name("warn")
.short("w")
Arg::new("warn")
.short('w')
.long("warn")
.help("warn about improperly formatted checksum lines"),
)
// Needed for variable-length output sums (e.g. SHAKE)
.arg(
Arg::with_name("bits")
Arg::new("bits")
.long("bits")
.help("set the size of the output (only for SHAKE)")
.takes_value(true)
@ -403,14 +401,15 @@ pub fn uu_app_common() -> App<'static, 'static> {
.validator(is_valid_bit_num),
)
.arg(
Arg::with_name("FILE")
Arg::new("FILE")
.index(1)
.multiple(true)
.value_name("FILE"),
.multiple_occurrences(true)
.value_name("FILE")
.allow_invalid_utf8(true),
)
}
pub fn uu_app_custom() -> App<'static, 'static> {
pub fn uu_app_custom<'a>() -> App<'a> {
let mut app = uu_app_common();
let algorithms = &[
("md5", "work with MD5"),
@ -436,14 +435,14 @@ pub fn uu_app_custom() -> App<'static, 'static> {
];
for (name, desc) in algorithms {
app = app.arg(Arg::with_name(name).long(name).help(desc));
app = app.arg(Arg::new(*name).long(name).help(*desc));
}
app
}
// hashsum is handled differently in build.rs, therefore this is not the same
// as in other utilities.
fn uu_app(binary_name: &str) -> App<'static, 'static> {
fn uu_app<'a>(binary_name: &str) -> App<'a> {
if !is_custom_binary(binary_name) {
uu_app_custom()
} else {

View file

@ -1,6 +1,6 @@
[package]
name = "uu_head"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "head ~ (uutils) display the first lines of input"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/head.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
memchr = "2"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -3,10 +3,10 @@
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// spell-checker:ignore (vars) zlines BUFWRITER
// spell-checker:ignore (vars) zlines BUFWRITER seekable
use clap::{crate_version, App, Arg};
use std::convert::TryFrom;
use std::convert::{TryFrom, TryInto};
use std::ffi::OsString;
use std::io::{self, BufWriter, ErrorKind, Read, Seek, SeekFrom, Write};
use uucore::display::Quotable;
@ -42,14 +42,14 @@ use lines::zlines;
use take::take_all_but;
use take::take_lines;
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.usage(USAGE)
.override_usage(USAGE)
.arg(
Arg::with_name(options::BYTES_NAME)
.short("c")
Arg::new(options::BYTES_NAME)
.short('c')
.long("bytes")
.value_name("[-]NUM")
.takes_value(true)
@ -64,8 +64,8 @@ pub fn uu_app() -> App<'static, 'static> {
.allow_hyphen_values(true),
)
.arg(
Arg::with_name(options::LINES_NAME)
.short("n")
Arg::new(options::LINES_NAME)
.short('n')
.long("lines")
.value_name("[-]NUM")
.takes_value(true)
@ -80,28 +80,28 @@ pub fn uu_app() -> App<'static, 'static> {
.allow_hyphen_values(true),
)
.arg(
Arg::with_name(options::QUIET_NAME)
.short("q")
Arg::new(options::QUIET_NAME)
.short('q')
.long("quiet")
.visible_alias("silent")
.help("never print headers giving file names")
.overrides_with_all(&[options::VERBOSE_NAME, options::QUIET_NAME]),
)
.arg(
Arg::with_name(options::VERBOSE_NAME)
.short("v")
Arg::new(options::VERBOSE_NAME)
.short('v')
.long("verbose")
.help("always print headers giving file names")
.overrides_with_all(&[options::QUIET_NAME, options::VERBOSE_NAME]),
)
.arg(
Arg::with_name(options::ZERO_NAME)
.short("z")
Arg::new(options::ZERO_NAME)
.short('z')
.long("zero-terminated")
.help("line delimiter is NUL, not newline")
.overrides_with(options::ZERO_NAME),
)
.arg(Arg::with_name(options::FILES_NAME).multiple(true))
.arg(Arg::new(options::FILES_NAME).multiple_occurrences(true))
}
#[derive(PartialEq, Debug, Clone, Copy)]
enum Modes {
@ -291,16 +291,95 @@ fn read_but_last_n_lines(
Ok(())
}
fn head_backwards_file(input: &mut std::fs::File, options: &HeadOptions) -> std::io::Result<()> {
assert!(options.all_but_last);
/// Return the index in `input` just after the `n`th line from the end.
///
/// If `n` exceeds the number of lines in this file, then return 0.
///
/// The cursor must be at the start of the seekable input before
/// calling this function. This function rewinds the cursor to the
/// beginning of the input just before returning unless there is an
/// I/O error.
///
/// If `zeroed` is `false`, interpret the newline character `b'\n'` as
/// a line ending. If `zeroed` is `true`, interpret the null character
/// `b'\0'` as a line ending instead.
///
/// # Errors
///
/// This function returns an error if there is a problem seeking
/// through or reading the input.
///
/// # Examples
///
/// The function returns the index of the byte immediately following
/// the line ending character of the `n`th line from the end of the
/// input:
///
/// ```rust,ignore
/// let mut input = Cursor::new("x\ny\nz\n");
/// assert_eq!(find_nth_line_from_end(&mut input, 0, false).unwrap(), 6);
/// assert_eq!(find_nth_line_from_end(&mut input, 1, false).unwrap(), 4);
/// assert_eq!(find_nth_line_from_end(&mut input, 2, false).unwrap(), 2);
/// ```
///
/// If `n` exceeds the number of lines in the file, always return 0:
///
/// ```rust,ignore
/// let mut input = Cursor::new("x\ny\nz\n");
/// assert_eq!(find_nth_line_from_end(&mut input, 3, false).unwrap(), 0);
/// assert_eq!(find_nth_line_from_end(&mut input, 4, false).unwrap(), 0);
/// assert_eq!(find_nth_line_from_end(&mut input, 1000, false).unwrap(), 0);
/// ```
fn find_nth_line_from_end<R>(input: &mut R, n: usize, zeroed: bool) -> std::io::Result<usize>
where
R: Read + Seek,
{
let size = input.seek(SeekFrom::End(0))?;
let size = usize::try_from(size).unwrap();
let mut buffer = [0u8; BUF_SIZE];
let buffer = &mut buffer[..BUF_SIZE.min(size)];
let mut i = 0usize;
let mut lines = 0usize;
loop {
// the casts here are ok, `buffer.len()` should never be above a few k
input.seek(SeekFrom::Current(
-((buffer.len() as i64).min((size - i) as i64)),
))?;
input.read_exact(buffer)?;
for byte in buffer.iter().rev() {
match byte {
b'\n' if !zeroed => {
lines += 1;
}
0u8 if zeroed => {
lines += 1;
}
_ => {}
}
// if it were just `n`,
if lines == n + 1 {
input.seek(SeekFrom::Start(0))?;
return Ok(size - i);
}
i += 1;
}
if size - i == 0 {
input.seek(SeekFrom::Start(0))?;
return Ok(0);
}
}
}
fn head_backwards_file(input: &mut std::fs::File, options: &HeadOptions) -> std::io::Result<()> {
assert!(options.all_but_last);
match options.mode {
Modes::Bytes(n) => {
let size = input.metadata()?.len().try_into().unwrap();
if n >= size {
return Ok(());
} else {
input.seek(SeekFrom::Start(0))?;
read_n_bytes(
&mut std::io::BufReader::with_capacity(BUF_SIZE, input),
size - n,
@ -308,41 +387,10 @@ fn head_backwards_file(input: &mut std::fs::File, options: &HeadOptions) -> std:
}
}
Modes::Lines(n) => {
let mut buffer = [0u8; BUF_SIZE];
let buffer = &mut buffer[..BUF_SIZE.min(size)];
let mut i = 0usize;
let mut lines = 0usize;
let found = 'o: loop {
// the casts here are ok, `buffer.len()` should never be above a few k
input.seek(SeekFrom::Current(
-((buffer.len() as i64).min((size - i) as i64)),
))?;
input.read_exact(buffer)?;
for byte in buffer.iter().rev() {
match byte {
b'\n' if !options.zeroed => {
lines += 1;
}
0u8 if options.zeroed => {
lines += 1;
}
_ => {}
}
// if it were just `n`,
if lines == n + 1 {
break 'o i;
}
i += 1;
}
if size - i == 0 {
return Ok(());
}
};
input.seek(SeekFrom::Start(0))?;
let found = find_nth_line_from_end(input, n, options.zeroed)?;
read_n_bytes(
&mut std::io::BufReader::with_capacity(BUF_SIZE, input),
size - found,
found,
)?;
}
}
@ -459,6 +507,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
#[cfg(test)]
mod tests {
use std::ffi::OsString;
use std::io::Cursor;
use super::*;
fn options(args: &str) -> Result<HeadOptions, String> {
@ -580,4 +629,15 @@ mod tests {
assert!(read_n_bytes(&mut empty, 0).is_ok());
assert!(read_n_lines(&mut empty, 0, false).is_ok());
}
#[test]
fn test_find_nth_line_from_end() {
let mut input = Cursor::new("x\ny\nz\n");
assert_eq!(find_nth_line_from_end(&mut input, 0, false).unwrap(), 6);
assert_eq!(find_nth_line_from_end(&mut input, 1, false).unwrap(), 4);
assert_eq!(find_nth_line_from_end(&mut input, 2, false).unwrap(), 2);
assert_eq!(find_nth_line_from_end(&mut input, 3, false).unwrap(), 0);
assert_eq!(find_nth_line_from_end(&mut input, 4, false).unwrap(), 0);
assert_eq!(find_nth_line_from_end(&mut input, 1000, false).unwrap(), 0);
}
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_hostid"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "hostid ~ (uutils) display the numeric identifier of the current host"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/hostid.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -25,10 +25,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.usage(SYNTAX)
.override_usage(SYNTAX)
}
fn hostid() {

View file

@ -1,6 +1,6 @@
[package]
name = "uu_hostname"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "hostname ~ (uutils) display or set the host name of the current host"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/hostname.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
hostname = { version = "0.3", features = ["set"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] }

View file

@ -61,7 +61,7 @@ fn usage() -> String {
#[uucore_procs::gen_uumain]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
#[cfg(windows)]
let _handle = wsa::start().map_err_context(|| "failed to start Winsock".to_owned())?;
@ -72,39 +72,39 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(OPT_DOMAIN)
.short("d")
Arg::new(OPT_DOMAIN)
.short('d')
.long("domain")
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
.help("Display the name of the DNS domain if possible"),
)
.arg(
Arg::with_name(OPT_IP_ADDRESS)
.short("i")
Arg::new(OPT_IP_ADDRESS)
.short('i')
.long("ip-address")
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
.help("Display the network address(es) of the host"),
)
.arg(
Arg::with_name(OPT_FQDN)
.short("f")
Arg::new(OPT_FQDN)
.short('f')
.long("fqdn")
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
.help("Display the FQDN (Fully Qualified Domain Name) (default)"),
)
.arg(
Arg::with_name(OPT_SHORT)
.short("s")
Arg::new(OPT_SHORT)
.short('s')
.long("short")
.overrides_with_all(&[OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT])
.help("Display the short hostname (the portion before the first dot) if possible"),
)
.arg(Arg::with_name(OPT_HOST))
.arg(Arg::new(OPT_HOST).allow_invalid_utf8(true))
}
fn display_hostname(matches: &ArgMatches) -> UResult<()> {

View file

@ -1,6 +1,6 @@
[package]
name = "uu_id"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "id ~ (uutils) display user and group information for USER"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/id.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "process"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
selinux = { version="0.2.1", optional = true }

View file

@ -132,7 +132,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let after_help = get_description();
let matches = uu_app()
.usage(&usage[..])
.override_usage(&usage[..])
.after_help(&after_help[..])
.get_matches_from(args);
@ -347,13 +347,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(options::OPT_AUDIT)
.short("A")
Arg::new(options::OPT_AUDIT)
.short('A')
.conflicts_with_all(&[
options::OPT_GROUP,
options::OPT_EFFECTIVE_USER,
@ -368,22 +368,22 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(options::OPT_EFFECTIVE_USER)
.short("u")
Arg::new(options::OPT_EFFECTIVE_USER)
.short('u')
.long(options::OPT_EFFECTIVE_USER)
.conflicts_with(options::OPT_GROUP)
.help("Display only the effective user ID as a number."),
)
.arg(
Arg::with_name(options::OPT_GROUP)
.short("g")
Arg::new(options::OPT_GROUP)
.short('g')
.long(options::OPT_GROUP)
.conflicts_with(options::OPT_EFFECTIVE_USER)
.help("Display only the effective group ID as a number"),
)
.arg(
Arg::with_name(options::OPT_GROUPS)
.short("G")
Arg::new(options::OPT_GROUPS)
.short('G')
.long(options::OPT_GROUPS)
.conflicts_with_all(&[
options::OPT_GROUP,
@ -399,13 +399,13 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(options::OPT_HUMAN_READABLE)
.short("p")
Arg::new(options::OPT_HUMAN_READABLE)
.short('p')
.help("Make the output human-readable. Each display is on a separate line."),
)
.arg(
Arg::with_name(options::OPT_NAME)
.short("n")
Arg::new(options::OPT_NAME)
.short('n')
.long(options::OPT_NAME)
.help(
"Display the name of the user or group ID for the -G, -g and -u options \
@ -414,13 +414,13 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(options::OPT_PASSWORD)
.short("P")
Arg::new(options::OPT_PASSWORD)
.short('P')
.help("Display the id as a password file entry."),
)
.arg(
Arg::with_name(options::OPT_REAL_ID)
.short("r")
Arg::new(options::OPT_REAL_ID)
.short('r')
.long(options::OPT_REAL_ID)
.help(
"Display the real ID for the -G, -g and -u options instead of \
@ -428,8 +428,8 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(options::OPT_ZERO)
.short("z")
Arg::new(options::OPT_ZERO)
.short('z')
.long(options::OPT_ZERO)
.help(
"delimit entries with NUL characters, not whitespace;\n\
@ -437,15 +437,15 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
.arg(
Arg::with_name(options::OPT_CONTEXT)
.short("Z")
Arg::new(options::OPT_CONTEXT)
.short('Z')
.long(options::OPT_CONTEXT)
.conflicts_with_all(&[options::OPT_GROUP, options::OPT_EFFECTIVE_USER])
.help(CONTEXT_HELP_TEXT),
)
.arg(
Arg::with_name(options::ARG_USERS)
.multiple(true)
Arg::new(options::ARG_USERS)
.multiple_occurrences(true)
.takes_value(true)
.value_name(options::ARG_USERS),
)

View file

@ -1,6 +1,6 @@
[package]
name = "uu_install"
version = "0.0.9"
version = "0.0.12"
authors = [
"Ben Eills <ben@beneills.com>",
"uutils developers",
@ -18,7 +18,7 @@ edition = "2018"
path = "src/install.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
filetime = "0.2"
file_diff = "1.0.0"
libc = ">= 0.2"

View file

@ -175,7 +175,7 @@ fn usage() -> String {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let paths: Vec<String> = matches
.values_of(ARG_FILES)
@ -192,7 +192,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
@ -203,67 +203,67 @@ pub fn uu_app() -> App<'static, 'static> {
backup_control::arguments::backup_no_args()
)
.arg(
Arg::with_name(OPT_IGNORED)
.short("c")
Arg::new(OPT_IGNORED)
.short('c')
.help("ignored")
)
.arg(
Arg::with_name(OPT_COMPARE)
.short("C")
Arg::new(OPT_COMPARE)
.short('C')
.long(OPT_COMPARE)
.help("compare each pair of source and destination files, and in some cases, do not modify the destination at all")
)
.arg(
Arg::with_name(OPT_DIRECTORY)
.short("d")
Arg::new(OPT_DIRECTORY)
.short('d')
.long(OPT_DIRECTORY)
.help("treat all arguments as directory names. create all components of the specified directories")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_CREATE_LEADING)
.short("D")
Arg::new(OPT_CREATE_LEADING)
.short('D')
.help("create all leading components of DEST except the last, then copy SOURCE to DEST")
)
.arg(
Arg::with_name(OPT_GROUP)
.short("g")
Arg::new(OPT_GROUP)
.short('g')
.long(OPT_GROUP)
.help("set group ownership, instead of process's current group")
.value_name("GROUP")
.takes_value(true)
)
.arg(
Arg::with_name(OPT_MODE)
.short("m")
Arg::new(OPT_MODE)
.short('m')
.long(OPT_MODE)
.help("set permission mode (as in chmod), instead of rwxr-xr-x")
.value_name("MODE")
.takes_value(true)
)
.arg(
Arg::with_name(OPT_OWNER)
.short("o")
Arg::new(OPT_OWNER)
.short('o')
.long(OPT_OWNER)
.help("set ownership (super-user only)")
.value_name("OWNER")
.takes_value(true)
)
.arg(
Arg::with_name(OPT_PRESERVE_TIMESTAMPS)
.short("p")
Arg::new(OPT_PRESERVE_TIMESTAMPS)
.short('p')
.long(OPT_PRESERVE_TIMESTAMPS)
.help("apply access/modification times of SOURCE files to corresponding destination files")
)
.arg(
Arg::with_name(OPT_STRIP)
.short("s")
Arg::new(OPT_STRIP)
.short('s')
.long(OPT_STRIP)
.help("strip symbol tables (no action Windows)")
)
.arg(
Arg::with_name(OPT_STRIP_PROGRAM)
Arg::new(OPT_STRIP_PROGRAM)
.long(OPT_STRIP_PROGRAM)
.help("program used to strip binaries (no action Windows)")
.value_name("PROGRAM")
@ -273,42 +273,42 @@ pub fn uu_app() -> App<'static, 'static> {
)
.arg(
// TODO implement flag
Arg::with_name(OPT_TARGET_DIRECTORY)
.short("t")
Arg::new(OPT_TARGET_DIRECTORY)
.short('t')
.long(OPT_TARGET_DIRECTORY)
.help("move all SOURCE arguments into DIRECTORY")
.value_name("DIRECTORY")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_NO_TARGET_DIRECTORY)
.short("T")
Arg::new(OPT_NO_TARGET_DIRECTORY)
.short('T')
.long(OPT_NO_TARGET_DIRECTORY)
.help("(unimplemented) treat DEST as a normal file")
)
.arg(
Arg::with_name(OPT_VERBOSE)
.short("v")
Arg::new(OPT_VERBOSE)
.short('v')
.long(OPT_VERBOSE)
.help("explain what is being done")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_PRESERVE_CONTEXT)
.short("P")
Arg::new(OPT_PRESERVE_CONTEXT)
.short('P')
.long(OPT_PRESERVE_CONTEXT)
.help("(unimplemented) preserve security context")
)
.arg(
// TODO implement flag
Arg::with_name(OPT_CONTEXT)
.short("Z")
Arg::new(OPT_CONTEXT)
.short('Z')
.long(OPT_CONTEXT)
.help("(unimplemented) set security context of files and directories")
.value_name("CONTEXT")
)
.arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true).min_values(1))
.arg(Arg::new(ARG_FILES).multiple_occurrences(true).takes_value(true).min_values(1))
}
/// Check for unimplemented command line arguments.

View file

@ -1,6 +1,6 @@
[package]
name = "uu_join"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "join ~ (uutils) merge lines from inputs with matching join fields"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/join.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -578,7 +578,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(NAME)
.version(crate_version!())
.about(
@ -587,12 +587,10 @@ standard output. The default join field is the first, delimited by blanks.
When FILE1 or FILE2 (not both) is -, read standard input.",
)
.help_message("display this help and exit")
.version_message("display version and exit")
.arg(
Arg::with_name("a")
.short("a")
.multiple(true)
Arg::new("a")
.short('a')
.multiple_occurrences(true)
.number_of_values(1)
.possible_values(&["1", "2"])
.value_name("FILENUM")
@ -602,92 +600,92 @@ FILENUM is 1 or 2, corresponding to FILE1 or FILE2",
),
)
.arg(
Arg::with_name("v")
.short("v")
.multiple(true)
Arg::new("v")
.short('v')
.multiple_occurrences(true)
.number_of_values(1)
.possible_values(&["1", "2"])
.value_name("FILENUM")
.help("like -a FILENUM, but suppress joined output lines"),
)
.arg(
Arg::with_name("e")
.short("e")
Arg::new("e")
.short('e')
.takes_value(true)
.value_name("EMPTY")
.help("replace missing input fields with EMPTY"),
)
.arg(
Arg::with_name("i")
.short("i")
Arg::new("i")
.short('i')
.long("ignore-case")
.help("ignore differences in case when comparing fields"),
)
.arg(
Arg::with_name("j")
.short("j")
Arg::new("j")
.short('j')
.takes_value(true)
.value_name("FIELD")
.help("equivalent to '-1 FIELD -2 FIELD'"),
)
.arg(
Arg::with_name("o")
.short("o")
Arg::new("o")
.short('o')
.takes_value(true)
.value_name("FORMAT")
.help("obey FORMAT while constructing output line"),
)
.arg(
Arg::with_name("t")
.short("t")
Arg::new("t")
.short('t')
.takes_value(true)
.value_name("CHAR")
.help("use CHAR as input and output field separator"),
)
.arg(
Arg::with_name("1")
.short("1")
Arg::new("1")
.short('1')
.takes_value(true)
.value_name("FIELD")
.help("join on this FIELD of file 1"),
)
.arg(
Arg::with_name("2")
.short("2")
Arg::new("2")
.short('2')
.takes_value(true)
.value_name("FIELD")
.help("join on this FIELD of file 2"),
)
.arg(Arg::with_name("check-order").long("check-order").help(
.arg(Arg::new("check-order").long("check-order").help(
"check that the input is correctly sorted, \
even if all input lines are pairable",
))
.arg(
Arg::with_name("nocheck-order")
Arg::new("nocheck-order")
.long("nocheck-order")
.help("do not check that the input is correctly sorted"),
)
.arg(Arg::with_name("header").long("header").help(
.arg(Arg::new("header").long("header").help(
"treat the first line in each file as field headers, \
print them without trying to pair them",
))
.arg(
Arg::with_name("z")
.short("z")
Arg::new("z")
.short('z')
.long("zero-terminated")
.help("line delimiter is NUL, not newline"),
)
.arg(
Arg::with_name("file1")
Arg::new("file1")
.required(true)
.value_name("FILE1")
.hidden(true),
.hide(true),
)
.arg(
Arg::with_name("file2")
Arg::new("file2")
.required(true)
.value_name("FILE2")
.hidden(true),
.hide(true),
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_kill"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "kill ~ (uutils) send a signal to a process"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/kill.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["signals"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -43,7 +43,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let obs_signal = handle_obsolete(&mut args);
let usage = format!("{} [OPTIONS]... PID...", uucore::execution_phrase());
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let mode = if matches.is_present(options::TABLE) || matches.is_present(options::TABLE_OLD) {
Mode::Table
@ -78,36 +78,36 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(options::LIST)
.short("l")
Arg::new(options::LIST)
.short('l')
.long(options::LIST)
.help("Lists signals")
.conflicts_with(options::TABLE)
.conflicts_with(options::TABLE_OLD),
)
.arg(
Arg::with_name(options::TABLE)
.short("t")
Arg::new(options::TABLE)
.short('t')
.long(options::TABLE)
.help("Lists table of signals"),
)
.arg(Arg::with_name(options::TABLE_OLD).short("L").hidden(true))
.arg(Arg::new(options::TABLE_OLD).short('L').hide(true))
.arg(
Arg::with_name(options::SIGNAL)
.short("s")
Arg::new(options::SIGNAL)
.short('s')
.long(options::SIGNAL)
.help("Sends given signal")
.takes_value(true),
)
.arg(
Arg::with_name(options::PIDS_OR_SIGNALS)
.hidden(true)
.multiple(true),
Arg::new(options::PIDS_OR_SIGNALS)
.hide(true)
.multiple_occurrences(true),
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_link"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "link ~ (uutils) create a hard (file system) link to FILE"
@ -16,9 +16,9 @@ path = "src/link.rs"
[dependencies]
libc = "0.2.42"
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }
clap = { version = "2.33", features = ["wrap_help"] }
[[bin]]
name = "link"

View file

@ -23,7 +23,7 @@ fn usage() -> String {
#[uucore_procs::gen_uumain]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let files: Vec<_> = matches
.values_of_os(options::FILES)
@ -36,16 +36,17 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.map_err_context(|| format!("cannot create link {} to {}", new.quote(), old.quote()))
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(options::FILES)
.hidden(true)
Arg::new(options::FILES)
.hide(true)
.required(true)
.min_values(2)
.max_values(2)
.takes_value(true),
.takes_value(true)
.allow_invalid_utf8(true),
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_ln"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "ln ~ (uutils) create a (file system) link to TARGET"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/ln.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -135,7 +135,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let long_usage = long_usage();
let matches = uu_app()
.usage(&usage[..])
.override_usage(&usage[..])
.after_help(&*format!(
"{}\n{}",
long_usage,
@ -179,30 +179,30 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
exec(&paths[..], &settings)
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(backup_control::arguments::backup())
.arg(backup_control::arguments::backup_no_args())
// TODO: opts.arg(
// Arg::with_name(("d", "directory", "allow users with appropriate privileges to attempt \
// Arg::new(("d", "directory", "allow users with appropriate privileges to attempt \
// to make hard links to directories");
.arg(
Arg::with_name(options::FORCE)
.short("f")
Arg::new(options::FORCE)
.short('f')
.long(options::FORCE)
.help("remove existing destination files"),
)
.arg(
Arg::with_name(options::INTERACTIVE)
.short("i")
Arg::new(options::INTERACTIVE)
.short('i')
.long(options::INTERACTIVE)
.help("prompt whether to remove existing destination files"),
)
.arg(
Arg::with_name(options::NO_DEREFERENCE)
.short("n")
Arg::new(options::NO_DEREFERENCE)
.short('n')
.long(options::NO_DEREFERENCE)
.help(
"treat LINK_NAME as a normal file if it is a \
@ -210,13 +210,13 @@ pub fn uu_app() -> App<'static, 'static> {
),
)
// TODO: opts.arg(
// Arg::with_name(("L", "logical", "dereference TARGETs that are symbolic links");
// Arg::new(("L", "logical", "dereference TARGETs that are symbolic links");
//
// TODO: opts.arg(
// Arg::with_name(("P", "physical", "make hard links directly to symbolic links");
// Arg::new(("P", "physical", "make hard links directly to symbolic links");
.arg(
Arg::with_name(options::SYMBOLIC)
.short("s")
Arg::new(options::SYMBOLIC)
.short('s')
.long("symbolic")
.help("make symbolic links instead of hard links")
// override added for https://github.com/uutils/coreutils/issues/2359
@ -224,35 +224,35 @@ pub fn uu_app() -> App<'static, 'static> {
)
.arg(backup_control::arguments::suffix())
.arg(
Arg::with_name(options::TARGET_DIRECTORY)
.short("t")
Arg::new(options::TARGET_DIRECTORY)
.short('t')
.long(options::TARGET_DIRECTORY)
.help("specify the DIRECTORY in which to create the links")
.value_name("DIRECTORY")
.conflicts_with(options::NO_TARGET_DIRECTORY),
)
.arg(
Arg::with_name(options::NO_TARGET_DIRECTORY)
.short("T")
Arg::new(options::NO_TARGET_DIRECTORY)
.short('T')
.long(options::NO_TARGET_DIRECTORY)
.help("treat LINK_NAME as a normal file always"),
)
.arg(
Arg::with_name(options::RELATIVE)
.short("r")
Arg::new(options::RELATIVE)
.short('r')
.long(options::RELATIVE)
.help("create symbolic links relative to link location")
.requires(options::SYMBOLIC),
)
.arg(
Arg::with_name(options::VERBOSE)
.short("v")
Arg::new(options::VERBOSE)
.short('v')
.long(options::VERBOSE)
.help("print name of each linked file"),
)
.arg(
Arg::with_name(ARG_FILES)
.multiple(true)
Arg::new(ARG_FILES)
.multiple_occurrences(true)
.takes_value(true)
.required(true)
.min_values(1),

View file

@ -1,6 +1,6 @@
[package]
name = "uu_logname"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "logname ~ (uutils) display the login name of the current user"
@ -16,7 +16,7 @@ path = "src/logname.rs"
[dependencies]
libc = "0.2.42"
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -45,7 +45,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.collect_str(InvalidEncodingHandling::Ignore)
.accept_any();
let _ = uu_app().usage(usage()).get_matches_from(args);
let _ = uu_app().override_usage(usage()).get_matches_from(args);
match get_userlogin() {
Some(userlogin) => println!("{}", userlogin),
@ -55,7 +55,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(SUMMARY)

View file

@ -1,6 +1,6 @@
[package]
name = "uu_ls"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "ls ~ (uutils) display directory contents"
@ -16,7 +16,7 @@ path = "src/ls.rs"
[dependencies]
chrono = "0.4.19"
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo", "env"] }
unicode-width = "0.1.8"
number_prefix = "0.4"
term_grid = "0.1.5"

View file

@ -687,7 +687,7 @@ impl Config {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage();
let app = uu_app().usage(&usage[..]);
let app = uu_app().override_usage(&usage[..]);
let matches = app.get_matches_from(args);
@ -701,7 +701,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
list(locs, config)
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(
@ -711,7 +711,7 @@ pub fn uu_app() -> App<'static, 'static> {
)
// Format arguments
.arg(
Arg::with_name(options::FORMAT)
Arg::new(options::FORMAT)
.long(options::FORMAT)
.help("Set the display format.")
.takes_value(true)
@ -736,8 +736,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::format::COLUMNS)
.short(options::format::COLUMNS)
Arg::new(options::format::COLUMNS)
.short('C')
.help("Display the files in columns.")
.overrides_with_all(&[
options::FORMAT,
@ -748,8 +748,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::format::LONG)
.short("l")
Arg::new(options::format::LONG)
.short('l')
.long(options::format::LONG)
.help("Display detailed information.")
.overrides_with_all(&[
@ -761,8 +761,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::format::ACROSS)
.short(options::format::ACROSS)
Arg::new(options::format::ACROSS)
.short('x')
.help("List entries in rows instead of in columns.")
.overrides_with_all(&[
options::FORMAT,
@ -773,8 +773,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::format::COMMAS)
.short(options::format::COMMAS)
Arg::new(options::format::COMMAS)
.short('m')
.help("List entries separated by commas.")
.overrides_with_all(&[
options::FORMAT,
@ -791,36 +791,36 @@ pub fn uu_app() -> App<'static, 'static> {
// ls -1g1
// even though `ls -11` and `ls -1 -g -1` work.
.arg(
Arg::with_name(options::format::ONE_LINE)
.short(options::format::ONE_LINE)
Arg::new(options::format::ONE_LINE)
.short('1')
.help("List one file per line.")
.multiple(true),
.multiple_occurrences(true),
)
.arg(
Arg::with_name(options::format::LONG_NO_GROUP)
.short(options::format::LONG_NO_GROUP)
Arg::new(options::format::LONG_NO_GROUP)
.short('o')
.help(
"Long format without group information. \
Identical to --format=long with --no-group.",
)
.multiple(true),
.multiple_occurrences(true),
)
.arg(
Arg::with_name(options::format::LONG_NO_OWNER)
.short(options::format::LONG_NO_OWNER)
Arg::new(options::format::LONG_NO_OWNER)
.short('g')
.help("Long format without owner information.")
.multiple(true),
.multiple_occurrences(true),
)
.arg(
Arg::with_name(options::format::LONG_NUMERIC_UID_GID)
.short("n")
Arg::new(options::format::LONG_NUMERIC_UID_GID)
.short('n')
.long(options::format::LONG_NUMERIC_UID_GID)
.help("-l with numeric UIDs and GIDs.")
.multiple(true),
.multiple_occurrences(true),
)
// Quoting style
.arg(
Arg::with_name(options::QUOTING_STYLE)
Arg::new(options::QUOTING_STYLE)
.long(options::QUOTING_STYLE)
.takes_value(true)
.help("Set quoting style.")
@ -841,8 +841,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::quoting::LITERAL)
.short("N")
Arg::new(options::quoting::LITERAL)
.short('N')
.long(options::quoting::LITERAL)
.help("Use literal quoting style. Equivalent to `--quoting-style=literal`")
.overrides_with_all(&[
@ -853,8 +853,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::quoting::ESCAPE)
.short("b")
Arg::new(options::quoting::ESCAPE)
.short('b')
.long(options::quoting::ESCAPE)
.help("Use escape quoting style. Equivalent to `--quoting-style=escape`")
.overrides_with_all(&[
@ -865,8 +865,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::quoting::C)
.short("Q")
Arg::new(options::quoting::C)
.short('Q')
.long(options::quoting::C)
.help("Use C quoting style. Equivalent to `--quoting-style=c`")
.overrides_with_all(&[
@ -878,21 +878,21 @@ pub fn uu_app() -> App<'static, 'static> {
)
// Control characters
.arg(
Arg::with_name(options::HIDE_CONTROL_CHARS)
.short("q")
Arg::new(options::HIDE_CONTROL_CHARS)
.short('q')
.long(options::HIDE_CONTROL_CHARS)
.help("Replace control characters with '?' if they are not escaped.")
.overrides_with_all(&[options::HIDE_CONTROL_CHARS, options::SHOW_CONTROL_CHARS]),
)
.arg(
Arg::with_name(options::SHOW_CONTROL_CHARS)
Arg::new(options::SHOW_CONTROL_CHARS)
.long(options::SHOW_CONTROL_CHARS)
.help("Show control characters 'as is' if they are not escaped.")
.overrides_with_all(&[options::HIDE_CONTROL_CHARS, options::SHOW_CONTROL_CHARS]),
)
// Time arguments
.arg(
Arg::with_name(options::TIME)
Arg::new(options::TIME)
.long(options::TIME)
.help(
"Show time in <field>:\n\
@ -910,8 +910,8 @@ pub fn uu_app() -> App<'static, 'static> {
.overrides_with_all(&[options::TIME, options::time::ACCESS, options::time::CHANGE]),
)
.arg(
Arg::with_name(options::time::CHANGE)
.short(options::time::CHANGE)
Arg::new(options::time::CHANGE)
.short('c')
.help(
"If the long listing format (e.g., -l, -o) is being used, print the status \
change time (the 'ctime' in the inode) instead of the modification time. When \
@ -921,8 +921,8 @@ pub fn uu_app() -> App<'static, 'static> {
.overrides_with_all(&[options::TIME, options::time::ACCESS, options::time::CHANGE]),
)
.arg(
Arg::with_name(options::time::ACCESS)
.short(options::time::ACCESS)
Arg::new(options::time::ACCESS)
.short('u')
.help(
"If the long listing format (e.g., -l, -o) is being used, print the status \
access time instead of the modification time. When explicitly sorting by time \
@ -933,33 +933,33 @@ pub fn uu_app() -> App<'static, 'static> {
)
// Hide and ignore
.arg(
Arg::with_name(options::HIDE)
Arg::new(options::HIDE)
.long(options::HIDE)
.takes_value(true)
.multiple(true)
.multiple_occurrences(true)
.value_name("PATTERN")
.help(
"do not list implied entries matching shell PATTERN (overridden by -a or -A)",
),
)
.arg(
Arg::with_name(options::IGNORE)
.short("I")
Arg::new(options::IGNORE)
.short('I')
.long(options::IGNORE)
.takes_value(true)
.multiple(true)
.multiple_occurrences(true)
.value_name("PATTERN")
.help("do not list implied entries matching shell PATTERN"),
)
.arg(
Arg::with_name(options::IGNORE_BACKUPS)
.short("B")
Arg::new(options::IGNORE_BACKUPS)
.short('B')
.long(options::IGNORE_BACKUPS)
.help("Ignore entries which end with ~."),
)
// Sort arguments
.arg(
Arg::with_name(options::SORT)
Arg::new(options::SORT)
.long(options::SORT)
.help("Sort by <field>: name, none (-U), time (-t), size (-S) or extension (-X)")
.value_name("field")
@ -976,8 +976,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::sort::SIZE)
.short(options::sort::SIZE)
Arg::new(options::sort::SIZE)
.short('S')
.help("Sort by file size, largest first.")
.overrides_with_all(&[
options::SORT,
@ -989,8 +989,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::sort::TIME)
.short(options::sort::TIME)
Arg::new(options::sort::TIME)
.short('t')
.help("Sort by modification time (the 'mtime' in the inode), newest first.")
.overrides_with_all(&[
options::SORT,
@ -1002,8 +1002,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::sort::VERSION)
.short(options::sort::VERSION)
Arg::new(options::sort::VERSION)
.short('v')
.help("Natural sort of (version) numbers in the filenames.")
.overrides_with_all(&[
options::SORT,
@ -1015,8 +1015,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::sort::EXTENSION)
.short(options::sort::EXTENSION)
Arg::new(options::sort::EXTENSION)
.short('X')
.help("Sort alphabetically by entry extension.")
.overrides_with_all(&[
options::SORT,
@ -1028,8 +1028,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::sort::NONE)
.short(options::sort::NONE)
Arg::new(options::sort::NONE)
.short('U')
.help(
"Do not sort; list the files in whatever order they are stored in the \
directory. This is especially useful when listing very large directories, \
@ -1046,8 +1046,8 @@ pub fn uu_app() -> App<'static, 'static> {
)
// Dereferencing
.arg(
Arg::with_name(options::dereference::ALL)
.short("L")
Arg::new(options::dereference::ALL)
.short('L')
.long(options::dereference::ALL)
.help(
"When showing file information for a symbolic link, show information for the \
@ -1060,7 +1060,7 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::dereference::DIR_ARGS)
Arg::new(options::dereference::DIR_ARGS)
.long(options::dereference::DIR_ARGS)
.help(
"Do not dereference symlinks except when they link to directories and are \
@ -1073,8 +1073,8 @@ pub fn uu_app() -> App<'static, 'static> {
]),
)
.arg(
Arg::with_name(options::dereference::ARGS)
.short("H")
Arg::new(options::dereference::ARGS)
.short('H')
.long(options::dereference::ARGS)
.help("Do not dereference symlinks except when given as command line arguments.")
.overrides_with_all(&[
@ -1085,25 +1085,25 @@ pub fn uu_app() -> App<'static, 'static> {
)
// Long format options
.arg(
Arg::with_name(options::NO_GROUP)
Arg::new(options::NO_GROUP)
.long(options::NO_GROUP)
.short("-G")
.short('G')
.help("Do not show group in long format."),
)
.arg(Arg::with_name(options::AUTHOR).long(options::AUTHOR).help(
.arg(Arg::new(options::AUTHOR).long(options::AUTHOR).help(
"Show author in long format. \
On the supported platforms, the author always matches the file owner.",
))
// Other Flags
.arg(
Arg::with_name(options::files::ALL)
.short("a")
Arg::new(options::files::ALL)
.short('a')
.long(options::files::ALL)
.help("Do not ignore hidden files (files with names that start with '.')."),
)
.arg(
Arg::with_name(options::files::ALMOST_ALL)
.short("A")
Arg::new(options::files::ALMOST_ALL)
.short('A')
.long(options::files::ALMOST_ALL)
.help(
"In a directory, do not ignore all file names that start with '.', \
@ -1111,8 +1111,8 @@ only ignore '.' and '..'.",
),
)
.arg(
Arg::with_name(options::DIRECTORY)
.short("d")
Arg::new(options::DIRECTORY)
.short('d')
.long(options::DIRECTORY)
.help(
"Only list the names of directories, rather than listing directory contents. \
@ -1122,26 +1122,26 @@ only ignore '.' and '..'.",
),
)
.arg(
Arg::with_name(options::size::HUMAN_READABLE)
.short("h")
Arg::new(options::size::HUMAN_READABLE)
.short('h')
.long(options::size::HUMAN_READABLE)
.help("Print human readable file sizes (e.g. 1K 234M 56G).")
.overrides_with(options::size::SI),
)
.arg(
Arg::with_name(options::size::SI)
Arg::new(options::size::SI)
.long(options::size::SI)
.help("Print human readable file sizes using powers of 1000 instead of 1024."),
)
.arg(
Arg::with_name(options::INODE)
.short("i")
Arg::new(options::INODE)
.short('i')
.long(options::INODE)
.help("print the index number of each file"),
)
.arg(
Arg::with_name(options::REVERSE)
.short("r")
Arg::new(options::REVERSE)
.short('r')
.long(options::REVERSE)
.help(
"Reverse whatever the sorting method is e.g., list files in reverse \
@ -1149,21 +1149,21 @@ only ignore '.' and '..'.",
),
)
.arg(
Arg::with_name(options::RECURSIVE)
.short("R")
Arg::new(options::RECURSIVE)
.short('R')
.long(options::RECURSIVE)
.help("List the contents of all directories recursively."),
)
.arg(
Arg::with_name(options::WIDTH)
Arg::new(options::WIDTH)
.long(options::WIDTH)
.short("w")
.short('w')
.help("Assume that the terminal is COLS columns wide.")
.value_name("COLS")
.takes_value(true),
)
.arg(
Arg::with_name(options::COLOR)
Arg::new(options::COLOR)
.long(options::COLOR)
.help("Color output based on file type.")
.takes_value(true)
@ -1174,7 +1174,7 @@ only ignore '.' and '..'.",
.min_values(0),
)
.arg(
Arg::with_name(options::INDICATOR_STYLE)
Arg::new(options::INDICATOR_STYLE)
.long(options::INDICATOR_STYLE)
.help(
"Append indicator with style WORD to entry names: \
@ -1190,8 +1190,8 @@ only ignore '.' and '..'.",
]),
)
.arg(
Arg::with_name(options::indicator_style::CLASSIFY)
.short("F")
Arg::new(options::indicator_style::CLASSIFY)
.short('F')
.long(options::indicator_style::CLASSIFY)
.help(
"Append a character to each file name indicating the file type. Also, for \
@ -1207,7 +1207,7 @@ only ignore '.' and '..'.",
]),
)
.arg(
Arg::with_name(options::indicator_style::FILE_TYPE)
Arg::new(options::indicator_style::FILE_TYPE)
.long(options::indicator_style::FILE_TYPE)
.help("Same as --classify, but do not append '*'")
.overrides_with_all(&[
@ -1218,8 +1218,8 @@ only ignore '.' and '..'.",
]),
)
.arg(
Arg::with_name(options::indicator_style::SLASH)
.short(options::indicator_style::SLASH)
Arg::new(options::indicator_style::SLASH)
.short('p')
.help("Append / indicator to directories.")
.overrides_with_all(&[
options::indicator_style::FILE_TYPE,
@ -1230,7 +1230,7 @@ only ignore '.' and '..'.",
)
.arg(
//This still needs support for posix-*, +FORMAT
Arg::with_name(options::TIME_STYLE)
Arg::new(options::TIME_STYLE)
.long(options::TIME_STYLE)
.help("time/date format with -l; see TIME_STYLE below")
.value_name("TIME_STYLE")
@ -1239,22 +1239,23 @@ only ignore '.' and '..'.",
.overrides_with_all(&[options::TIME_STYLE]),
)
.arg(
Arg::with_name(options::FULL_TIME)
Arg::new(options::FULL_TIME)
.long(options::FULL_TIME)
.overrides_with(options::FULL_TIME)
.help("like -l --time-style=full-iso"),
)
.arg(
Arg::with_name(options::CONTEXT)
.short("Z")
Arg::new(options::CONTEXT)
.short('Z')
.long(options::CONTEXT)
.help(CONTEXT_HELP_TEXT),
)
// Positional arguments
.arg(
Arg::with_name(options::PATHS)
.multiple(true)
.takes_value(true),
Arg::new(options::PATHS)
.multiple_occurrences(true)
.takes_value(true)
.allow_invalid_utf8(true),
)
.after_help(
"The TIME_STYLE argument can be full-iso, long-iso, iso. \

View file

@ -1,6 +1,6 @@
[package]
name = "uu_mkdir"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "mkdir ~ (uutils) create DIRECTORY"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/mkdir.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -96,7 +96,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// opts.optflag("Z", "context", "set SELinux security context" +
// " of each created directory to CTX"),
let matches = uu_app()
.usage(&usage[..])
.override_usage(&usage[..])
.after_help(&after_help[..])
.get_matches_from(args);
@ -110,35 +110,36 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(options::MODE)
.short("m")
Arg::new(options::MODE)
.short('m')
.long(options::MODE)
.help("set file mode (not implemented on windows)")
.default_value("755"),
)
.arg(
Arg::with_name(options::PARENTS)
.short("p")
Arg::new(options::PARENTS)
.short('p')
.long(options::PARENTS)
.alias("parent")
.help("make parent directories as needed"),
)
.arg(
Arg::with_name(options::VERBOSE)
.short("v")
Arg::new(options::VERBOSE)
.short('v')
.long(options::VERBOSE)
.help("print a message for each printed directory"),
)
.arg(
Arg::with_name(options::DIRS)
.multiple(true)
Arg::new(options::DIRS)
.multiple_occurrences(true)
.takes_value(true)
.min_values(1),
.min_values(1)
.allow_invalid_utf8(true),
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_mkfifo"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "mkfifo ~ (uutils) create FIFOs (named pipes)"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/mkfifo.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -69,27 +69,27 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(())
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.name(NAME)
.version(crate_version!())
.usage(USAGE)
.override_usage(USAGE)
.about(SUMMARY)
.arg(
Arg::with_name(options::MODE)
.short("m")
Arg::new(options::MODE)
.short('m')
.long(options::MODE)
.help("file permissions for the fifo")
.default_value("0666")
.value_name("0666"),
)
.arg(
Arg::with_name(options::SE_LINUX_SECURITY_CONTEXT)
.short(options::SE_LINUX_SECURITY_CONTEXT)
Arg::new(options::SE_LINUX_SECURITY_CONTEXT)
.short('Z')
.help("set the SELinux security context to default type"),
)
.arg(
Arg::with_name(options::CONTEXT)
Arg::new(options::CONTEXT)
.long(options::CONTEXT)
.value_name("CTX")
.help(
@ -97,5 +97,9 @@ pub fn uu_app() -> App<'static, 'static> {
or SMACK security context to CTX",
),
)
.arg(Arg::with_name(options::FIFO).hidden(true).multiple(true))
.arg(
Arg::new(options::FIFO)
.hide(true)
.multiple_occurrences(true),
)
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_mknod"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "mknod ~ (uutils) create special file NAME of TYPE"
@ -16,7 +16,7 @@ name = "uu_mknod"
path = "src/mknod.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "^0.2.42"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["mode"] }
uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" }

View file

@ -143,28 +143,28 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.usage(USAGE)
.override_usage(USAGE)
.after_help(LONG_HELP)
.about(ABOUT)
.arg(
Arg::with_name("mode")
.short("m")
Arg::new("mode")
.short('m')
.long("mode")
.value_name("MODE")
.help("set file permission bits to MODE, not a=rw - umask"),
)
.arg(
Arg::with_name("name")
Arg::new("name")
.value_name("NAME")
.help("name of the new file")
.required(true)
.index(1),
)
.arg(
Arg::with_name("type")
Arg::new("type")
.value_name("TYPE")
.help("type of the new file (b, c, u or p)")
.required(true)
@ -172,14 +172,14 @@ pub fn uu_app() -> App<'static, 'static> {
.index(2),
)
.arg(
Arg::with_name("major")
Arg::new("major")
.value_name("MAJOR")
.help("major file type")
.validator(valid_u64)
.index(3),
)
.arg(
Arg::with_name("minor")
Arg::new("minor")
.value_name("MINOR")
.help("minor file type")
.validator(valid_u64)
@ -202,7 +202,7 @@ fn get_mode(matches: &ArgMatches) -> Result<mode_t, String> {
}
}
fn valid_type(tpe: String) -> Result<(), String> {
fn valid_type(tpe: &str) -> Result<(), String> {
// Only check the first character, to allow mnemonic usage like
// 'mknod /dev/rst0 character 18 0'.
tpe.chars()
@ -217,6 +217,6 @@ fn valid_type(tpe: String) -> Result<(), String> {
})
}
fn valid_u64(num: String) -> Result<(), String> {
num.parse::<u64>().map(|_| ()).map_err(|_| num)
fn valid_u64(num: &str) -> Result<(), String> {
num.parse::<u64>().map(|_| ()).map_err(|_| num.into())
}

View file

@ -1,6 +1,6 @@
[package]
name = "uu_mktemp"
version = "0.0.9"
version = "0.0.12"
authors = ["uutils developers"]
license = "MIT"
description = "mktemp ~ (uutils) create and display a temporary file or directory from TEMPLATE"
@ -15,7 +15,7 @@ edition = "2018"
path = "src/mktemp.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
rand = "0.5"
tempfile = "3.1"
uucore = { version=">=0.0.11", package="uucore", path="../../uucore" }

Some files were not shown because too many files have changed in this diff Show more