Improve the arguments 🦀
This commit is contained in:
parent
4af3c47a5d
commit
d04c5973ea
5 changed files with 15 additions and 11 deletions
|
@ -2,6 +2,6 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DiscordProjectSettings">
|
<component name="DiscordProjectSettings">
|
||||||
<option name="show" value="PROJECT_FILES" />
|
<option name="show" value="PROJECT_FILES" />
|
||||||
<option name="description" value="Writing more tests yooo :D" />
|
<option name="description" value="Finshing yoo :D" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -12,7 +12,6 @@ keywords = [
|
||||||
"interpreter",
|
"interpreter",
|
||||||
"repl",
|
"repl",
|
||||||
"bf",
|
"bf",
|
||||||
"bf-interpreter",
|
|
||||||
"bf-repl",
|
"bf-repl",
|
||||||
"brainfuck-interpreter",
|
"brainfuck-interpreter",
|
||||||
"brainfuck-repl",
|
"brainfuck-repl",
|
||||||
|
@ -34,7 +33,7 @@ exclude = [
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.0.14", features = ["derive", "color", "cargo"] }
|
clap = { version = "4.0.14", features = ["derive", "color", "cargo", "wrap_help", "suggestions"] }
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
pretty_env_logger = "0.4.0"
|
pretty_env_logger = "0.4.0"
|
||||||
colored = "2.0.0"
|
colored = "2.0.0"
|
||||||
|
|
|
@ -20,9 +20,20 @@ pub struct Args {
|
||||||
pub enum Feature {
|
pub enum Feature {
|
||||||
/// If the value is you want decrement the value and the value is 0, don't set the value to 255, otherwise decrement the value.
|
/// If the value is you want decrement the value and the value is 0, don't set the value to 255, otherwise decrement the value.
|
||||||
/// If the value is you want increment the value and the value is 255, don't set the value to 0, otherwise increment the value.
|
/// If the value is you want increment the value and the value is 255, don't set the value to 0, otherwise increment the value.
|
||||||
|
/// The alias are: `nrv`
|
||||||
|
#[clap(alias = "nrv")]
|
||||||
NoReverseValue,
|
NoReverseValue,
|
||||||
/// If the pointer at the end of the array, set the pointer to 0, otherwise increment the pointer.
|
/// If the pointer at the end of the array, set the pointer to 0, otherwise increment the pointer.
|
||||||
/// If the pointer at the beginning of the array, set the pointer to the end of the array, otherwise decrement the pointer.
|
/// If the pointer at the beginning of the array, set the pointer to the end of the array, otherwise decrement the pointer.
|
||||||
|
/// The alias are: `rp`
|
||||||
|
#[clap(alias = "rp")]
|
||||||
ReversePointer,
|
ReversePointer,
|
||||||
|
/// Allow the use of utf8 characters (32 bit), otherwise only 8 bit characters are allowed.
|
||||||
|
/// Use this feature with caution because it increases the cell size from 8 bits to 32 bits.
|
||||||
|
/// It also allow you to use the emoji in your brainfuck code :D,
|
||||||
|
/// This is if you can preserve your mind so that you can access their digital value :).
|
||||||
|
/// The `u32` in rust can only store values from 0 to 4294967295, but we can only use 0 to 1114111 (0x10FFFF) for now.
|
||||||
|
/// The alias are: `utf8`
|
||||||
|
#[clap(alias = "utf8")]
|
||||||
AllowUtf8,
|
AllowUtf8,
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,10 +102,6 @@ mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(error.code, 13);
|
assert_eq!(error.code, 13);
|
||||||
|
|
||||||
/*let error = InterpreterErrorKind::FlushError(e).to_error();
|
|
||||||
assert_eq!(error.to_string(), "Failed to read byte from stdin: no bytes available");
|
|
||||||
assert_eq!(error.code, 14);*/
|
|
||||||
|
|
||||||
let error = InterpreterErrorKind::UnmatchedBracket.to_error();
|
let error = InterpreterErrorKind::UnmatchedBracket.to_error();
|
||||||
assert_eq!(error.to_string(), "Unmatched bracket");
|
assert_eq!(error.to_string(), "Unmatched bracket");
|
||||||
assert_eq!(error.code, 15);
|
assert_eq!(error.code, 15);
|
||||||
|
|
|
@ -19,13 +19,11 @@ fn main() {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
info!("Parsed command line arguments: {:?}", args);
|
info!("Parsed command line arguments: {:?}", args);
|
||||||
|
|
||||||
let term = console::Term::stdout();
|
|
||||||
|
|
||||||
info!("Initializing interpreter");
|
info!("Initializing interpreter");
|
||||||
let mut interpreter = Interpreter::new(
|
let mut interpreter = Interpreter::new(
|
||||||
args.array_size,
|
args.array_size,
|
||||||
args.features.unwrap_or_else(|| vec![]),
|
args.features.unwrap_or_else(|| vec![]),
|
||||||
term,
|
console::Term::stdout(),
|
||||||
);
|
);
|
||||||
|
|
||||||
match args.source {
|
match args.source {
|
||||||
|
@ -41,7 +39,7 @@ fn main() {
|
||||||
println!(
|
println!(
|
||||||
"{}",
|
"{}",
|
||||||
format!(
|
format!(
|
||||||
"Successfully ran brainfuck source code from file: {}",
|
"Successfully run brainfuck source code from file: {}",
|
||||||
source
|
source
|
||||||
)
|
)
|
||||||
.bold()
|
.bold()
|
||||||
|
|
Loading…
Reference in a new issue