diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 2e9ee5f..0fcf340 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,6 +42,7 @@ fn main() { let mut next_is_load = false; let mut no_stdlib = false; + let mut help = false; for arg in env::args() { if next_is_load { @@ -54,9 +55,10 @@ fn main() { s if s.ends_with("myslip") => continue, "-l" | "--load" => next_is_load = true, "--no-stdlib" => no_stdlib = true, + "--help" | "-h" | "-?" => help = true, s => match file_to_execute { Some(n) => { - println!("Error: can't execute both '{}' and '{}', please specify just one file", s, n); + println!("Error: can't execute both '{}' and '{}', please specify just one file. See '--help' for correct syntax.", s, n); return; }, None => file_to_execute = Some(s.to_string()), @@ -64,9 +66,29 @@ fn main() { } } + if help { + println!("{}", String::from("") + + "myslip [options] [file]\n" + + "\n" + + "If [file] is given, executes the s-expression contained by\n" + + "the file. Otherwise starts the myslip repl.\n" + + "\n" + + "Options:\n" + + "\n" + + " --load [defs] | -l [defs] loads declarations from file\n" + + " named [defs] before execution\n" + + "\n" + + " --no-stdlib stops myslip from loading the\n" + + " standard library at startup\n" + + "\n" + + " --help | -h | -? displays this help message\n" + + ); + return; + } if next_is_load { println!( -"Error: '--load' can't be the last element of the argument list " +"Error: '--load' can't be the last element of the argument list. See '--help' for correct syntax." ); return; } @@ -87,7 +109,7 @@ fn main() { match file_to_execute { Some(name) => { - let mut exp = match read_file_to_execute(name) { + let exp = match read_file_to_execute(name) { Ok(e) => e, Err(e) => { println!("Error reading source file: {e}"); |