diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..0f24c2c --- /dev/null +++ b/src/main.rs @@ -0,0 +1,60 @@ +use switchboard::*; + + +fn main() { + let mut args = Switchboard::from_env(); + args.named("version"); + args.named("verbose").short('v'); + match args.peek() { + Some("run") => { args.pop(); run_program(args) } + Some("asm") => { args.pop(); assemble_program(args) } + _ => run_program(args), + } +} + +fn run_program(mut args: Switchboard) { + println!("RUN PROGRAM"); + + args.positional("source").required(); + args.named("debug").short('d'); + args.named("fullscreen").short('f'); + args.named("zoom").short('z').quick("3").default("1"); + args.raise_errors(); + + let verbose = args.get("verbose").as_bool(); + let version = args.get("version").as_bool(); + let debug = args.get("debug").as_bool(); + let fullscreen = args.get("fullscreen").as_bool(); + let zoom = args.get("zoom").as_u32(); + let source = args.get("source").as_path(); + + println!("Verbose: {verbose:?}"); + println!("Version: {version:?}"); + println!("Source path: {source:?}"); + println!("Debug: {debug:?}"); + println!("Fullscreen: {fullscreen:?}"); + println!("Zoom: {zoom:?}"); +} + +fn assemble_program(mut args: Switchboard) { + println!("ASSEMBLE PROGRAM"); + + args.positional("source"); + args.positional("destination"); + args.positional("extension").default("brc"); + args.named("no-libs"); + args.named("no-project-libs"); + args.raise_errors(); + + let source_path = args.get("source").as_path(); + let destination_path = args.get("destination").as_path(); + let extension = args.get("extension").as_string(); + let no_libs = args.get("no-libs").as_bool(); + let no_project_libs = args.get("no-project-libs").as_bool(); + + println!("Source path: {source_path:?}"); + println!("Destination path: {destination_path:?}"); + println!("Extension: {extension:?}"); + println!("No libs: {no_libs:?}"); + println!("No project libs: {no_project_libs:?}"); +} |