1use crate::{build_info, pretty_print_elapsed};
8use anyhow::Result;
9use clap::{Parser, Subcommand};
10
11use super::GlobalArgs;
12
13pub mod ess;
14pub mod hyperball;
15
16#[derive(Subcommand, Debug)]
17#[command(name = "dist")]
18pub enum SubCommands {
19 #[clap(name = "hyperball", visible_alias = "hb")]
20 HyperBall(hyperball::CliArgs),
21 #[clap(visible_alias = "ess")]
22 ExactSumSweep(ess::CliArgs),
23}
24
25#[derive(Parser, Debug)]
26#[command(name = "webgraph-dist", version=build_info::version_string())]
27#[doc = include_str!("../common_ps.txt")]
29#[doc = include_str!("../common_env.txt")]
30pub struct Cli {
31 #[clap(flatten)]
32 args: GlobalArgs,
33 #[command(subcommand)]
34 command: SubCommands,
35}
36
37pub fn cli_main<I, T>(args: I) -> Result<()>
38where
39 I: IntoIterator<Item = T>,
40 T: Into<std::ffi::OsString> + Clone,
41{
42 let start = std::time::Instant::now();
43 let cli = Cli::parse_from(args);
44 match cli.command {
45 SubCommands::HyperBall(args) => {
46 hyperball::main(cli.args, args)?;
47 }
48 SubCommands::ExactSumSweep(args) => {
49 ess::main(cli.args, args)?;
50 }
51 }
52
53 log::info!(
54 "The command took {}",
55 pretty_print_elapsed(start.elapsed().as_secs_f64())
56 );
57
58 Ok(())
59}