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")]
29pub struct Cli {
44 #[clap(flatten)]
45 args: GlobalArgs,
46 #[command(subcommand)]
47 command: SubCommands,
48}
49
50pub fn cli_main<I, T>(args: I) -> Result<()>
51where
52 I: IntoIterator<Item = T>,
53 T: Into<std::ffi::OsString> + Clone,
54{
55 let start = std::time::Instant::now();
56 let cli = Cli::parse_from(args);
57 match cli.command {
58 SubCommands::HyperBall(args) => {
59 hyperball::main(cli.args, args)?;
60 }
61 SubCommands::ExactSumSweep(args) => {
62 ess::main(cli.args, args)?;
63 }
64 }
65
66 log::info!(
67 "The command took {}",
68 pretty_print_elapsed(start.elapsed().as_secs_f64())
69 );
70
71 Ok(())
72}