1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-04 15:07:47 +00:00

refactor/polish ~ fix cargo clippy complaints ('better' as println!())

This commit is contained in:
Roy Ivy III 2019-12-28 12:45:11 -06:00
parent 291d2f5d48
commit 413c64fa12
27 changed files with 58 additions and 59 deletions

View file

@ -80,7 +80,7 @@ fn maybe_handle_help_or_version(args: &[String]) -> bool {
fn print_help() {
//! The following is taken from GNU coreutils' "expr --help" output.
print!(
println!(
r#"Usage: expr EXPRESSION
or: expr OPTION
@ -131,8 +131,7 @@ Environment variables:
* EXPR_DEBUG_TOKENS=1 dump expression's tokens
* EXPR_DEBUG_RPN=1 dump expression represented in reverse polish notation
* EXPR_DEBUG_SYA_STEP=1 dump each parser step
* EXPR_DEBUG_AST=1 dump expression represented abstract syntax tree
"#
* EXPR_DEBUG_AST=1 dump expression represented abstract syntax tree"#
);
}

View file

@ -107,7 +107,7 @@ fn table() {
//TODO: obtain max signal width here
if (idx + 1) % 7 == 0 {
println!("");
println!();
}
}
}
@ -133,7 +133,7 @@ fn print_signals() {
pos += signal.name.len();
print!("{}", signal.name);
if idx > 0 && pos > 73 {
println!("");
println!();
pos = 0;
} else {
pos += 1;

View file

@ -295,7 +295,7 @@ fn link(src: &PathBuf, dst: &PathBuf, settings: &Settings) -> Result<()> {
print!("'{}' -> '{}'", dst.display(), src.display());
match backup_path {
Some(path) => println!(" (backup: '{}')", path.display()),
None => println!(""),
None => println!(),
}
}
Ok(())

View file

@ -76,7 +76,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
fn print_help(opts: &getopts::Options) {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
print!(
"{}",

View file

@ -164,5 +164,5 @@ fn more(matches: getopts::Matches) {
}
reset_term(&mut term);
println!("");
println!();
}

View file

@ -387,7 +387,7 @@ fn rename(from: &PathBuf, to: &PathBuf, b: &Behaviour) -> Result<()> {
print!("{} -> {}", from.display(), to.display());
match backup_path {
Some(path) => println!(" (backup: {})", path.display()),
None => println!(""),
None => println!(),
}
}
Ok(())

View file

@ -272,7 +272,7 @@ fn nl<T: Read>(reader: &mut BufReader<T>, settings: &Settings) {
if matched_groups > 0 {
// The current line is a section delimiter, so we output
// a blank line.
println!("");
println!();
// However the line does not count as a blank line, so we
// reset the counter used for --join-blank-lines.
empty_line_count = 0;

View file

@ -315,10 +315,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
let matches = opts.parse(&args[1..]).unwrap();
if matches.opt_present("help") {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {0} [STRING]... [OPTION]...", NAME);
println!("");
println!();
print!(
"{}",
opts.usage("Convert numbers from/to human-readable strings")

View file

@ -263,7 +263,7 @@ impl Pinky {
}
}
println!("");
println!();
}
fn print_heading(&self) {
@ -279,7 +279,7 @@ impl Pinky {
if self.include_where {
print!(" Where");
}
println!("");
println!();
}
fn short_pinky(&self) -> IOResult<()> {
@ -325,7 +325,7 @@ impl Pinky {
read_to_console(f);
}
}
println!("");
println!();
} else {
println!(" ???");
}

View file

@ -139,7 +139,7 @@ fn show(path: &PathBuf, no_newline: bool, use_zero: bool) {
fn show_usage(opts: &getopts::Options) {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage: {0} [OPTION]... [FILE]...", NAME);
print!("Print value of a symbolic link or canonical file name");
print!("{}", opts.usage(""));

View file

@ -136,12 +136,12 @@ fn version() {
fn show_usage(opts: &getopts::Options) {
version();
println!("");
println!();
println!("Usage:");
println!(" {} [-s|--strip] [-z|--zero] FILENAME...", NAME);
println!(" {} -V|--version", NAME);
println!(" {} -h|--help", NAME);
println!("");
println!();
print!("{}", opts.usage(
"Convert each FILENAME to the absolute path.\n\
All the symbolic links will be resolved, resulting path will contain no special components like '.' or '..'.\n\

View file

@ -108,12 +108,12 @@ fn version() {
fn show_usage(opts: &getopts::Options) {
version();
println!("");
println!();
println!("Usage:");
println!(" {} [-d DIR] TO [FROM]", NAME);
println!(" {} -V|--version", NAME);
println!(" {} -h|--help", NAME);
println!("");
println!();
print!(
"{}",
opts.usage(

View file

@ -84,20 +84,20 @@ pub fn uumain(args: Vec<String>) -> i32 {
if matches.opt_present("help") {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {0} [OPTION]... [FILE]...", NAME);
println!("");
println!();
println!("{}", opts.usage("Remove (unlink) the FILE(s)."));
println!("By default, rm does not remove directories. Use the --recursive (-r)");
println!("option to remove each listed directory, too, along with all of its contents");
println!("");
println!();
println!("To remove a file whose name starts with a '-', for example '-foo',");
println!("use one of these commands:");
println!("rm -- -foo");
println!("");
println!();
println!("rm ./-foo");
println!("");
println!();
println!("Note that if you use rm to remove a file, it might be possible to recover");
println!("some of its contents, given sufficient expertise and/or time. For greater");
println!("assurance that the contents are truly unrecoverable, consider using shred.");

View file

@ -290,7 +290,7 @@ fn show_help(opts: &getopts::Options) {
println!("Delete FILE(s) if --remove (-u) is specified. The default is not to remove");
println!("the files because it is common to operate on device files like /dev/hda,");
println!("and those files usually should not be removed.");
println!("");
println!();
println!(
"CAUTION: Note that {} relies on a very important assumption:",
NAME
@ -302,20 +302,20 @@ fn show_help(opts: &getopts::Options) {
NAME
);
println!("not effective, or is not guaranteed to be effective in all file system modes:");
println!("");
println!();
println!("* log-structured or journaled file systems, such as those supplied with");
println!("AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)");
println!("");
println!();
println!("* file systems that write redundant data and carry on even if some writes");
println!("fail, such as RAID-based file systems");
println!("");
println!();
println!("* file systems that make snapshots, such as Network Appliance's NFS server");
println!("");
println!();
println!("* file systems that cache in temporary locations, such as NFS");
println!("version 3 clients");
println!("");
println!();
println!("* compressed file systems");
println!("");
println!();
println!("In the case of ext3 file systems, the above disclaimer applies");
println!(
"(and {} is thus of limited effectiveness) only in data=journal mode,",
@ -329,7 +329,7 @@ fn show_help(opts: &getopts::Options) {
println!("Ext3 journaling modes can be changed by adding the data=something option");
println!("to the mount options for a particular file system in the /etc/fstab file,");
println!("as documented in the mount man page (man mount).");
println!("");
println!();
println!("In addition, file system backups and remote mirrors may contain copies");
println!("of the file that cannot be removed, and that will allow a shredded file");
println!("to be recovered later.");

View file

@ -86,9 +86,9 @@ fn print_usage(opts: &Options) {
Also some filters (like 'dd' and 'cat' etc.) don't use streams for I/O, \
and are thus unaffected by 'stdbuf' settings.\n";
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage: stdbuf OPTION... COMMAND");
println!("");
println!();
println!("{}\n{}", opts.usage(brief), explanation);
}

View file

@ -147,7 +147,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
fn version() {
println!("{} (uutils) {}", NAME, VERSION);
println!("The MIT License");
println!("");
println!();
println!("Author -- Alexander Fomin.");
}

View file

@ -95,9 +95,9 @@ pub fn uumain(args: Vec<String>) -> i32 {
if matches.opt_present("help") || matches.free.is_empty() {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage: {} [OPTION]... FILE...", NAME);
println!("");
println!();
println!(
"{}",
opts.usage(

View file

@ -178,10 +178,10 @@ fn translate_input<T: SymbolTranslator>(
fn usage(opts: &Options) {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {} [OPTIONS] SET1 [SET2]", NAME);
println!("");
println!();
println!("{}", opts.usage("Translate or delete characters."));
}

View file

@ -58,10 +58,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
if matches.opt_present("help") {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {} [OPTION]... FILE...", NAME);
println!("");
println!();
print!(
"{}",
opts.usage("Shrink or extend the size of each file to the specified size.")

View file

@ -36,10 +36,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
if matches.opt_present("h") {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {} [OPTIONS] FILE", NAME);
println!("");
println!();
println!("{}", opts.usage("Topological sort the strings in FILE. Strings are defined as any sequence of tokens separated by whitespace (tab, space, or newline). If FILE is not passed in, stdin is used instead."));
return 0;
}

View file

@ -41,10 +41,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
if matches.opt_present("help") {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {} [OPTION]...", NAME);
println!("");
println!();
print!(
"{}",
opts.usage("Print the file name of the terminal connected to standard input.")

View file

@ -252,10 +252,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
if matches.opt_present("help") {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {0} [OPTION]... [FILE]...", NAME);
println!("");
println!();
print!(
"{}",
opts.usage(
@ -263,7 +263,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
writing to OUTPUT (or standard output)."
)
);
println!("");
println!();
println!(
"Note: '{0}' does not detect repeated lines unless they are adjacent.\n\
You may want to sort the input first, or use 'sort -u' without '{0}'.\n",

View file

@ -40,10 +40,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
if matches.opt_present("help") {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {} [FILE]... [OPTION]...", NAME);
println!("");
println!();
println!("{}", opts.usage("Unlink the file at [FILE]."));
return 0;
}

View file

@ -50,10 +50,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
if matches.opt_present("help") || !matches.free.is_empty() {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {0} [OPTION]", NAME);
println!("");
println!();
println!(
"{}",
opts.usage(

View file

@ -37,10 +37,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
if matches.opt_present("help") {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {} [OPTION]... [FILE]", NAME);
println!("");
println!();
println!(
"{}",
opts.usage("Output who is currently logged in according to FILE.")

View file

@ -24,7 +24,7 @@ include!(concat!(env!("OUT_DIR"), "/uutils_map.rs"));
fn usage(cmap: &UtilityMap) {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {} [util [arguments...]]\n", NAME);
println!("Currently defined functions:");

View file

@ -90,10 +90,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
if matches.opt_present("help") {
println!("{} {}", NAME, VERSION);
println!("");
println!();
println!("Usage:");
println!(" {0} [OPTION]... [FILE]...", NAME);
println!("");
println!();
println!(
"{}",
opts.usage("Print newline, word and byte counts for each FILE")
@ -254,7 +254,7 @@ fn print_stats(settings: &Settings, result: &Result, max_width: usize) {
if result.title != "-" {
println!(" {}", result.title);
} else {
println!("");
println!();
}
}