mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
mkdir init
This commit is contained in:
parent
d296841f1c
commit
512ae48161
1 changed files with 69 additions and 0 deletions
69
mkdir/mkdir.rs
Normal file
69
mkdir/mkdir.rs
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
#[crate_id(name="mkdir", vers="1.0.0", author="Nicholas Juszczak")];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the uutils coreutils package.
|
||||||
|
*
|
||||||
|
* (c) Nicholas Juszczak <juszczakn@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern mod extra;
|
||||||
|
|
||||||
|
use std::os;
|
||||||
|
use std::io::stderr;
|
||||||
|
use extra::getopts::groups;
|
||||||
|
use std::io::fs::mkdir;
|
||||||
|
use std::path;
|
||||||
|
|
||||||
|
static VERSION: &'static str = "1.0.0";
|
||||||
|
|
||||||
|
fn print_help(opts: &[groups::OptGroup]) {
|
||||||
|
println!("mkdir v{} - make a new directory with the given path", VERSION);
|
||||||
|
println("");
|
||||||
|
println("Usage:");
|
||||||
|
print(groups::usage("Create the given DIRECTORY(ies)" +
|
||||||
|
" if they do not exist", opts));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args: ~[~str] = os::args();
|
||||||
|
let program: ~str = args[0].clone();
|
||||||
|
|
||||||
|
let opts: ~[groups::OptGroup] = ~[
|
||||||
|
//groups::optflag("m", "mode", "set file mode"),
|
||||||
|
groups::optflag("p", "parents", "make parent directories as needed"),
|
||||||
|
groups::optflag("v", "verbose",
|
||||||
|
"print a message for each printed directory"),
|
||||||
|
groups::optflag("", "help", "display this help"),
|
||||||
|
groups::optflag("", "version", "display this version")
|
||||||
|
];
|
||||||
|
|
||||||
|
let matches = match groups::getopts(args.tail(), opts) {
|
||||||
|
Ok(m) => m,
|
||||||
|
Err(f) => {
|
||||||
|
writeln!(&mut stderr() as &mut Writer,
|
||||||
|
"Invalid options\n{}", f.to_err_msg());
|
||||||
|
os::set_exit_status(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if matches.opt_present("help") {
|
||||||
|
print_help(opts);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if matches.opt_present("version") {
|
||||||
|
println("mkdir v" + VERSION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let parents: bool = matches.opt_present("parents");
|
||||||
|
mkdir(parents);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mkdir(mk_parents: bool) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue