diff --git a/srp_analysis/Cargo.toml b/srp_analysis/Cargo.toml index cb6789f8378ce6ff6973d02aa0a38583a1d70d14..2ffa9443aa21086a1bccfef0958561522ee89b6d 100644 --- a/srp_analysis/Cargo.toml +++ b/srp_analysis/Cargo.toml @@ -7,3 +7,4 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +structopt = { version = "0.3"} diff --git a/srp_analysis/src/main.rs b/srp_analysis/src/main.rs index fd2ddac9a78562e63d6ee411f0e0a2476ac837c0..d303ec278ff3970999f231794c81b565b3ff0bd4 100644 --- a/srp_analysis/src/main.rs +++ b/srp_analysis/src/main.rs @@ -4,19 +4,54 @@ mod srp_analyser; use common::*; use srp_analyser::*; +use std::path::PathBuf; +use structopt::StructOpt; + + +#[derive(Debug, StructOpt)] +#[structopt(name = "srp_analysis", about = "Preforms srp analysis.")] +struct Opt { + /// Approximate preemptions + #[structopt(short, long)] + approx: bool, + + /// Input file, example input if not present + #[structopt(parse(from_os_str))] + input: Option<PathBuf>, + + /// Output file, stdout if not present + #[structopt(parse(from_os_str))] + output: Option<PathBuf>, +} -fn main() { - let tasks: Tasks = create_tasks(); - println!("tasks {:?}", &tasks); - println!("tot_util {}", total_load_factor(&tasks)); +fn main() { + let opt = Opt::from_args(); + println!("{:?}", opt); + + let tasks: Tasks = match opt.input { + Some(_file) => create_tasks(), // TODO: Implement so that the tasks can be read from file. + None => create_tasks(), + }; + let (ip, tr) = pre_analysis(&tasks); - println!("ip: {:?}", ip); - println!("tr: {:?}", tr); + let analysis = analyse(&tasks, &ip, &tr, opt.approx); + + match opt.output { + Some(_file) => (), // TODO: Implement so that the analysis can be saved to file. + None => { + println!("tasks {:?}", &tasks); + println!("tot_util {}", total_load_factor(&tasks)); + + println!("ip: {:?}", ip); + println!("tr: {:?}", tr); - let analysis = analyse(&tasks, &ip, &tr, true); - println!("Analysis {:#?}", analysis); + println!("Analysis {:#?}", analysis); + + // TODO: Implement a nicer print out to stdout. + }, + }; }