Add verbose for mkdir

This commit is contained in:
g1n 2021-07-21 08:22:23 +00:00
parent 6b7fe8d20a
commit 40f8120357
2 changed files with 8 additions and 1 deletions

View File

@ -4,7 +4,7 @@ WIP
grsh - simple shell written in rust
Also some other tools (not builin in grsh)
Also some other tools (not builtin in grsh)
## TODO

View File

@ -2,6 +2,7 @@ use std::env;
use std::fs;
fn main(){
let mut verbose_flag = false;
let args: Vec<String> = env::args().collect();
for arg in 1..args.len() {
match args[arg].as_str() {
@ -9,8 +10,14 @@ fn main(){
println!("Usage: mkdir [OPTIONS] DIRECTORY");
return;
}
"-v" | "--verbose" => {
verbose_flag = true;
}
arg => {
fs::create_dir_all(arg.to_string());
if verbose_flag {
println!("mkdir: created directory '{}'", arg);
}
}
}
}