mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-06-23 19:21:26 +02:00
Added help.
This commit is contained in:
parent
c50534a248
commit
3a25a3d416
@ -21,7 +21,20 @@ fn main() {
|
|||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
if arg == "-i" {
|
match arg.as_ref() {
|
||||||
|
"-h" | "--help" => {
|
||||||
|
// The indentation... Will have to do something more scalable in the future.
|
||||||
|
println!(
|
||||||
|
"
|
||||||
|
-= kalk help =-\n
|
||||||
|
kalk [OPTIONS] [INPUT]
|
||||||
|
-h, --help : show this
|
||||||
|
-i : load a file with predefined functions/variables
|
||||||
|
"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
"-i" => {
|
||||||
let file_name = &args.next().expect("Expected input file."); // The next argument will be the file name.
|
let file_name = &args.next().expect("Expected input file."); // The next argument will be the file name.
|
||||||
let mut file_content = String::new();
|
let mut file_content = String::new();
|
||||||
File::open(&file_name)
|
File::open(&file_name)
|
||||||
@ -33,12 +46,14 @@ fn main() {
|
|||||||
// Output is not needed here.
|
// Output is not needed here.
|
||||||
parser::eval(&mut parser_context, &file_content, 53)
|
parser::eval(&mut parser_context, &file_content, 53)
|
||||||
.expect("Failed to parse input file.");
|
.expect("Failed to parse input file.");
|
||||||
} else {
|
}
|
||||||
|
_ => {
|
||||||
// Main argument. This is expected to be a maths expression.
|
// Main argument. This is expected to be a maths expression.
|
||||||
// After the loop is finished, this will be parsed and outputted.
|
// After the loop is finished, this will be parsed and outputted.
|
||||||
expr_input = Some(arg);
|
expr_input = Some(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(input) = expr_input {
|
if let Some(input) = expr_input {
|
||||||
// Direct output
|
// Direct output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user