usage
This commit is contained in:
+7
-6
@@ -14,6 +14,7 @@ fn main() {
|
||||
Mat::Ingot,
|
||||
Mat::Gem,
|
||||
];
|
||||
usage();
|
||||
print_priority(&priority);
|
||||
let input = std::io::stdin();
|
||||
for line in input.lines() {
|
||||
@@ -21,15 +22,15 @@ fn main() {
|
||||
println!("error reading line");
|
||||
continue;
|
||||
};
|
||||
let Some((cmd, args)) = line.split_once(" ") else {
|
||||
println!("space expected after command");
|
||||
continue;
|
||||
let (cmd, args) = match line.split_once(" ") {
|
||||
Some(v) => v,
|
||||
None => (line.as_str(), ""),
|
||||
};
|
||||
match cmd {
|
||||
"solve" => run_solve(args, &priority),
|
||||
"priority" => run_priority(args, &mut priority),
|
||||
_ => {
|
||||
println!("unknown command");
|
||||
println!("unknown command {cmd}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,7 +117,7 @@ fn run_priority(args: &str, priority: &mut Priority) {
|
||||
}
|
||||
|
||||
fn print_priority(priority: &Priority) {
|
||||
println!("priority:");
|
||||
println!("current priority:");
|
||||
for (i, mat) in priority.iter().enumerate() {
|
||||
println!(" {}: {mat:?}", i + 1);
|
||||
}
|
||||
@@ -133,7 +134,7 @@ fn validate_priority(priority: &Priority) -> bool {
|
||||
}
|
||||
|
||||
fn usage() {
|
||||
println!("Usage:");
|
||||
println!("usage:");
|
||||
println!(" > solve 41/63 50/60 55/55 43/64 60/66 51/55 48/59 41/63");
|
||||
println!(" solves for the least number of materials needed given a priority");
|
||||
println!(" > priority wood paper grains string oil meat");
|
||||
|
||||
Reference in New Issue
Block a user