fn run() -> Result<()> {
    let matches = App::new("IBCM (Itty Bitty Computing Machine)")
        .version(VERSION)
        .author("Ian Johnson <ianprime0509@gmail.com>")
        .subcommand(SubCommand::with_name("compile")
                        .arg(Arg::with_name("INPUT")
                                 .help("The program data file to compile")
                                 .required(true))
                        .arg(Arg::with_name("binary")
                                 .short("b")
                                 .long("binary")
                                 .help("Outputs a binary file instead of a hexadecimal listing"))
                        .arg(Arg::with_name("hex")
                                 .short("x")
                                 .long("hex")
                                 .help("Processes the input as a hexadecimal listing"))
                        .arg(Arg::with_name("output")
                                 .short("o")
                                 .long("output")
                                 .value_name("FILE")
                                 .default_value("ibcm.out")
                                 .help("Sets the output file name")
                                 .takes_value(true)))
        .subcommand(SubCommand::with_name("debug")
                        .arg(Arg::with_name("INPUT")
                                 .help("The program to debug")
                                 .required(true))
                        .arg(Arg::with_name("asm")
                                 .conflicts_with("binary")
                                 .short("s")
                                 .long("asm")
                                 .help("Processes the input as an ICBM assembly file"))
                        .arg(Arg::with_name("binary")
                                 .short("b")
                                 .long("binary")
                                 .help("Processes the input as a binary file")))
        .subcommand(SubCommand::with_name("execute")
                        .arg(Arg::with_name("INPUT")
                                 .help("The program data file to load")
                                 .required(true))
                        .arg(Arg::with_name("asm")
                                 .conflicts_with("binary")
                                 .short("s")
                                 .long("asm")
                                 .help("Processes the input as an ICBM assembly file"))
                        .arg(Arg::with_name("binary")
                                 .short("b")
                                 .long("binary")
                                 .help("Processes the input as a binary file")))
        .subcommand(SubCommand::with_name("ibcmc")
                        .arg(Arg::with_name("INPUT")
                                 .help("The IBCMC source file to compile")
                                 .required(true))
                        .arg(Arg::with_name("output")
                                 .short("o")
                                 .long("output")
                                 .value_name("OUTPUT")
                                 .help("Sets the output file name")
                                 .takes_value(true)))
        .get_matches();

    match matches.subcommand() {
        ("compile", Some(sub_m)) => compile(sub_m),
        ("debug", Some(sub_m)) => debug(sub_m),
        ("execute", Some(sub_m)) => execute(sub_m),
        ("ibcmc", Some(sub_m)) => ibcmc(sub_m),
        _ => {
            println!("{}", matches.usage());
            Ok(())
        }
    }
}
/// Program logic goes in this function (for more convenient error handling).
Program logic goes in this function (for more convenient error handling).
Program logic goes in this function ( for more convenient error handling ) .
fn run() -> Result<()> {
    let matches = App::new("IBCM (Itty Bitty Computing Machine)")
        .version(VERSION)
        .author("Ian Johnson <ianprime0509@gmail.com>")
        .subcommand(SubCommand::with_name("compile")
                        .arg(Arg::with_name("INPUT")
                                 .help("The program data file to compile")
                                 .required(true))
                        .arg(Arg::with_name("binary")
                                 .short("b")
                                 .long("binary")
                                 .help("Outputs a binary file instead of a hexadecimal listing"))
                        .arg(Arg::with_name("hex")
                                 .short("x")
                                 .long("hex")
                                 .help("Processes the input as a hexadecimal listing"))
                        .arg(Arg::with_name("output")
                                 .short("o")
                                 .long("output")
                                 .value_name("FILE")
                                 .default_value("ibcm.out")
                                 .help("Sets the output file name")
                                 .takes_value(true)))
        .subcommand(SubCommand::with_name("debug")
                        .arg(Arg::with_name("INPUT")
                                 .help("The program to debug")
                                 .required(true))
                        .arg(Arg::with_name("asm")
                                 .conflicts_with("binary")
                                 .short("s")
                                 .long("asm")
                                 .help("Processes the input as an ICBM assembly file"))
                        .arg(Arg::with_name("binary")
                                 .short("b")
                                 .long("binary")
                                 .help("Processes the input as a binary file")))
        .subcommand(SubCommand::with_name("execute")
                        .arg(Arg::with_name("INPUT")
                                 .help("The program data file to load")
                                 .required(true))
                        .arg(Arg::with_name("asm")
                                 .conflicts_with("binary")
                                 .short("s")
                                 .long("asm")
                                 .help("Processes the input as an ICBM assembly file"))
                        .arg(Arg::with_name("binary")
                                 .short("b")
                                 .long("binary")
                                 .help("Processes the input as a binary file")))
        .subcommand(SubCommand::with_name("ibcmc")
                        .arg(Arg::with_name("INPUT")
                                 .help("The IBCMC source file to compile")
                                 .required(true))
                        .arg(Arg::with_name("output")
                                 .short("o")
                                 .long("output")
                                 .value_name("OUTPUT")
                                 .help("Sets the output file name")
                                 .takes_value(true)))
        .get_matches();
    match matches.subcommand() {
        ("compile", Some(sub_m)) => compile(sub_m),
        ("debug", Some(sub_m)) => debug(sub_m),
        ("execute", Some(sub_m)) => execute(sub_m),
        ("ibcmc", Some(sub_m)) => ibcmc(sub_m),
        _ => {
            println!("{}", matches.usage());
            Ok(())
        }
    }
}
fn run ( ) -> Result < ( ) > { let matches = App :: new ( " " ) . version ( VERSION ) . author ( " " ) . subcommand ( SubCommand :: with_name ( " " ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . required ( true ) ) . arg ( Arg :: with_name ( " " ) . short ( " " ) . long ( " " ) . help ( " " ) ) . arg ( Arg :: with_name ( " " ) . short ( " " ) . long ( " " ) . help ( " " ) ) . arg ( Arg :: with_name ( " " ) . short ( " " ) . long ( " " ) . value_name ( " " ) . default_value ( " " ) . help ( " " ) . takes_value ( true ) ) ) . subcommand ( SubCommand :: with_name ( " " ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . required ( true ) ) . arg ( Arg :: with_name ( " " ) . conflicts_with ( " " ) . short ( " " ) . long ( " " ) . help ( " " ) ) . arg ( Arg :: with_name ( " " ) . short ( " " ) . long ( " " ) . help ( " " ) ) ) . subcommand ( SubCommand :: with_name ( " " ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . required ( true ) ) . arg ( Arg :: with_name ( " " ) . conflicts_with ( " " ) . short ( " " ) . long ( " " ) . help ( " " ) ) . arg ( Arg :: with_name ( " " ) . short ( " " ) . long ( " " ) . help ( " " ) ) ) . subcommand ( SubCommand :: with_name ( " " ) . arg ( Arg :: with_name ( " " ) . help ( " " ) . required ( true ) ) . arg ( Arg :: with_name ( " " ) . short ( " " ) . long ( " " ) . value_name ( " " ) . help ( " " ) . takes_value ( true ) ) ) . get_matches ( ) ; match matches . subcommand ( ) { ( " " , Some ( sub_m ) ) => compile ( sub_m ) , ( " " , Some ( sub_m ) ) => debug ( sub_m ) , ( " " , Some ( sub_m ) ) => execute ( sub_m ) , ( " " , Some ( sub_m ) ) => ibcmc ( sub_m ) , _ => { println ! ( " " matches usage ( ) ) ; Ok ( ( ) ) } } }
Program logic goes in this function (for more convenient error handling).
Program logic goes in this function ( for more convenient error handling ) .