diff --git a/coreutils/src/commands/dd.rs b/coreutils/src/commands/dd.rs index c3da024..410b629 100644 --- a/coreutils/src/commands/dd.rs +++ b/coreutils/src/commands/dd.rs @@ -1,8 +1,8 @@ use boxutils::commands::Command; -use std::env; use std::collections::HashMap; -use std::io::{self, Read, Write, BufReader}; +use std::env; use std::fs::File; +use std::io::{self, BufReader, Read, Write}; use std::time::Instant; pub struct Dd; @@ -17,7 +17,7 @@ impl Command for Dd { if let Some((k, v)) = argument.split_once('=') { arguments.insert(k.to_string().to_lowercase(), v.to_string()); } // don't handle anything that does not follow dd's syntax. - // TODO: inform about malformed arguments + // TODO: inform about malformed arguments } if let Some(bs) = arguments.get("bs") { @@ -25,7 +25,7 @@ impl Command for Dd { if v.parse::().is_ok() { // assume the bs is specified in bytes, // because the last char is a number - blocksize = bs.parse::().unwrap() + blocksize = bs.parse::().unwrap() } else { match v { "K" | "k" => blocksize = k.parse::().unwrap() * 1024, @@ -36,7 +36,7 @@ impl Command for Dd { "GB" => blocksize = k.parse::().unwrap() * 1000 * 1000 * 1000, _ => { eprintln!("Invalid blocksize specified."); - return + return; } } } @@ -66,15 +66,10 @@ impl Command for Dd { println!( "{}+{} records in", // TODO: actually calculate records in - out_blocks, - out_remainder + out_blocks, out_remainder ); - println!( - "{}+{} records out", - out_blocks, - out_remainder - ); + println!("{}+{} records out", out_blocks, out_remainder); println!( "{} bytes ({}B) copied, {:.6} seconds, {:.2}KB/s", @@ -82,7 +77,6 @@ impl Command for Dd { vecbuf.len(), duration, kb_per_sec - ) } } diff --git a/coreutils/src/commands/nproc.rs b/coreutils/src/commands/nproc.rs index eaf58f0..5519aed 100644 --- a/coreutils/src/commands/nproc.rs +++ b/coreutils/src/commands/nproc.rs @@ -1,7 +1,7 @@ -use boxutils::commands::Command; use boxutils::args::ArgParser; -use std::env; +use boxutils::commands::Command; use num_cpus::{get, get_physical}; +use std::env; pub struct Nproc; @@ -17,7 +17,7 @@ impl Command for Nproc { let mut all = false; if args.get_flag("--help") { println!( -" + " Usage: nproc [--all] [ignore=N] Prints the number of available CPUs to stdout. @@ -25,7 +25,7 @@ Prints the number of available CPUs to stdout. --ignore=N, --ignore N Ignore N CPUs " ); - return + return; } if args.get_flag("--all") { diff --git a/coreutils/src/lib.rs b/coreutils/src/lib.rs index 6be336e..82b6da3 100644 --- a/coreutils/src/lib.rs +++ b/coreutils/src/lib.rs @@ -1 +1 @@ -pub mod commands; \ No newline at end of file +pub mod commands; diff --git a/shell/src/ash.rs b/shell/src/ash.rs index 89f6010..73ed7b4 100644 --- a/shell/src/ash.rs +++ b/shell/src/ash.rs @@ -1,8 +1,8 @@ use boxutils::commands::Command; use std::env; -use std::process::Command as stdCommand; -use std::io::{self, Write, ErrorKind}; +use std::io::{self, ErrorKind, Write}; use std::path::Path; +use std::process::Command as stdCommand; pub struct Ash; @@ -26,16 +26,14 @@ impl Command for Ash { let new_path = arguments.next(); let new_path = Path::new(new_path.unwrap()); let _ = env::set_current_dir(&new_path).is_ok(); - }, + } command => { - let out = stdCommand::new(command) - .args(arguments) - .spawn(); + let out = stdCommand::new(command).args(arguments).spawn(); match out { Ok(mut out) => { - let _ = out.wait(); - }, + let _ = out.wait(); + } Err(err) => match err.kind() { ErrorKind::NotFound => { eprintln!("ash: {}: not found", command); @@ -46,9 +44,9 @@ impl Command for Ash { _ => { eprintln!("ash: uncaught error: {}", err); } - } + }, } - }, + } } } }