Commit 4e384b94 authored by SJFrK's avatar SJFrK

Change handling of arguments.

Allows for chained short options (e.g. -Clx)
parent 3721268b
......@@ -208,28 +208,71 @@ impl Editor {
};
let mut files: Vec<String> = Vec::new();
let mut args_iter = args().skip(1).peekable();
loop {
let arg = match args_iter.next() {
Some(x) => x,
None => break
};
for arg in args().skip(1) {
match arg.as_str() {
"--version" => {
println!("Sodium {}", option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"));
return;
},
"--help" | "-h" => {
"--help" => {
println!("{}", HELP);
return;
}
"-R" => {
},
"-u" => {
unimplemented!();
/*
match editor.options.set("readonly") {
Ok(_) => debugln!(editor, "Set readonly mode"),
Err(_) => println!("Could not set readonly mode")
match args_iter.peek() {
Some(config) => {
// this is the config file to use for this session
println!("{}", config);
},
None => {
panic!("No config file specified.");
}
}
args_iter.next();
*/
}
"--" => {
// everything from here on out is a file
for file in args_iter {
files.push(file);
}
break;
}
_ => {
files.push(arg);
let mut arg_chars = arg.chars();
if arg_chars.next() == Some('-') {
for ch in arg_chars {
match ch {
'R' => {
unimplemented!();
/*
match editor.options.set("readonly") {
Ok(_) => debugln!(editor, "Set readonly mode"),
Err(_) => println!("Could not set readonly mode")
}
*/
},
'h' => {
println!("{}", HELP);
return;
},
_ => {
unimplemented!();
}
}
}
}
files.push(arg.clone());
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment