Fix argument order.

This commit is contained in:
chriseth 2022-10-28 16:01:21 +02:00
parent ad121f7250
commit 49fae419a9
2 changed files with 11 additions and 6 deletions

View file

@ -35,7 +35,7 @@ and the maximum amount of circles to transfer.
The options are:
`cargo run --release --bin cli <from> <to> [<max_hops> [<max_amount>]] <edges.dat>] [--dot <dotfile>]`
`cargo run --release --bin cli <from> <to> <edges.dat> [<max_hops> [<max_amount>]] [--dot <dotfile>]`
For example
@ -43,4 +43,4 @@ For example
Computes a transfer of at most `1000000000000000000`, exploring 3 hops.
If you specify `--dot <dotfile>`, a graphviz/dot representation of the transfer graph is written to the given file.
If you specify `--dot <dotfile>`, a graphviz/dot representation of the transfer graph is written to the given file.

View file

@ -23,22 +23,27 @@ fn main() {
if args.len() < 4 {
println!("Usage: cli <from> <to> <edges.dat> [--dot <dotfile>]");
println!("Usage: cli <from> <to> <max_hops> <edges.dat> [--dot <dotfile>]");
println!("Usage: cli <from> <to> <max_hops> <max_flow> <edges.dat> [--dot <dotfile>]");
println!("Usage: cli <from> <to> <edges.dat> <max_hops> [--dot <dotfile>]");
println!("Usage: cli <from> <to> <edges.dat> <max_hops> <max_flow> [--dot <dotfile>]");
return;
}
let mut max_hops = None;
let mut max_flow = U256::MAX;
let (from_str, to_str, edges_file) = (&args[1], &args[2], &args[3]);
if args.len() >= 5 {
max_hops = Some(args[4].parse().unwrap());
max_hops = Some(
args[4]
.parse()
.unwrap_or_else(|_| panic!("Expected number of hops, but got: {}", args[4])),
);
if args.len() >= 6 {
max_flow = args[5].as_str().into();
}
}
println!("Computing flow {from_str} -> {to_str} using {edges_file}");
let edges = io::read_edges_binary(edges_file).expect("Error loading edges.");
let edges = io::read_edges_binary(edges_file)
.unwrap_or_else(|_| panic!("Error loading edges from file \"{edges_file}\"."));
println!("Read {} edges", edges.len());
let (flow, transfers) = graph::compute_flow(
&Address::from(from_str.as_str()),