Add not builtin command - touch
This commit is contained in:
parent
3f0160f2f6
commit
b77a44a031
|
@ -0,0 +1,21 @@
|
|||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::path::Path;
|
||||
|
||||
fn main(){
|
||||
let args: Vec<String> = env::args().collect();
|
||||
for arg in 1..args.len() {
|
||||
match args[arg].as_str() {
|
||||
"--help" => {
|
||||
println!("Usage: touch [OPTIONS] FILE");
|
||||
println!("Creates empty file");
|
||||
return;
|
||||
},
|
||||
arg => {
|
||||
if !Path::new(arg).exists() {
|
||||
File::create(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue