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">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
<option name="description" value="Writing more tests yooo :D" />
|
||||
<option name="description" value="Finshing yoo :D" />
|
||||
</component>
|
||||
</project>
|
|
@ -12,7 +12,6 @@ keywords = [
|
|||
"interpreter",
|
||||
"repl",
|
||||
"bf",
|
||||
"bf-interpreter",
|
||||
"bf-repl",
|
||||
"brainfuck-interpreter",
|
||||
"brainfuck-repl",
|
||||
|
@ -34,7 +33,7 @@ exclude = [
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[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"
|
||||
pretty_env_logger = "0.4.0"
|
||||
colored = "2.0.0"
|
||||
|
|
|
@ -20,9 +20,20 @@ pub struct Args {
|
|||
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 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,
|
||||
/// 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.
|
||||
/// The alias are: `rp`
|
||||
#[clap(alias = "rp")]
|
||||
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,
|
||||
}
|
||||
|
|
|
@ -102,10 +102,6 @@ mod tests {
|
|||
);
|
||||
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();
|
||||
assert_eq!(error.to_string(), "Unmatched bracket");
|
||||
assert_eq!(error.code, 15);
|
||||
|
|
|
@ -19,13 +19,11 @@ fn main() {
|
|||
let args = Args::parse();
|
||||
info!("Parsed command line arguments: {:?}", args);
|
||||
|
||||
let term = console::Term::stdout();
|
||||
|
||||
info!("Initializing interpreter");
|
||||
let mut interpreter = Interpreter::new(
|
||||
args.array_size,
|
||||
args.features.unwrap_or_else(|| vec![]),
|
||||
term,
|
||||
console::Term::stdout(),
|
||||
);
|
||||
|
||||
match args.source {
|
||||
|
@ -41,7 +39,7 @@ fn main() {
|
|||
println!(
|
||||
"{}",
|
||||
format!(
|
||||
"Successfully ran brainfuck source code from file: {}",
|
||||
"Successfully run brainfuck source code from file: {}",
|
||||
source
|
||||
)
|
||||
.bold()
|
||||
|
|
Loading…
Reference in a new issue