2022-10-07 19:54:49 +00:00
|
|
|
use clap::{arg, Parser, ValueEnum};
|
2022-10-07 18:17:21 +00:00
|
|
|
|
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
#[command(author, about, long_about = None, version)]
|
|
|
|
pub struct Args {
|
|
|
|
/// The brainfuck source code file to run (if not will be entered in REPL mode)
|
2022-10-07 19:54:49 +00:00
|
|
|
#[arg(default_value = None)]
|
2022-10-07 18:17:21 +00:00
|
|
|
pub source: Option<String>,
|
2022-10-13 17:30:28 +00:00
|
|
|
/// The extra features to enable
|
2022-10-07 19:54:49 +00:00
|
|
|
#[arg(short, long, default_value = None)]
|
|
|
|
pub features: Option<Vec<Feature>>,
|
2022-10-07 18:17:21 +00:00
|
|
|
/// The brainfuck array size
|
|
|
|
#[arg(short, long, default_value = "30000")]
|
|
|
|
pub array_size: usize,
|
2022-10-08 07:35:40 +00:00
|
|
|
/// Dont print the tiles (e.g. exit code, file name, etc)
|
|
|
|
#[arg(short, long)]
|
|
|
|
pub without_tiles: bool,
|
2022-10-07 19:54:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Copy, Clone, ValueEnum)]
|
|
|
|
pub enum Feature {
|
2022-10-10 20:55:50 +00:00
|
|
|
/// 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.
|
2022-10-13 16:47:28 +00:00
|
|
|
/// The alias are: `nrv`
|
|
|
|
#[clap(alias = "nrv")]
|
2022-10-10 20:55:50 +00:00
|
|
|
NoReverseValue,
|
2022-10-07 19:54:49 +00:00
|
|
|
/// 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.
|
2022-10-13 16:47:28 +00:00
|
|
|
/// The alias are: `rp`
|
|
|
|
#[clap(alias = "rp")]
|
2022-10-07 19:54:49 +00:00
|
|
|
ReversePointer,
|
2022-10-13 16:47:28 +00:00
|
|
|
/// 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")]
|
2022-10-10 20:55:50 +00:00
|
|
|
AllowUtf8,
|
2022-10-07 23:06:35 +00:00
|
|
|
}
|