webgraph_cli/build/
mod.rs

1/*
2 * SPDX-FileCopyrightText: 2023 Tommaso Fontana
3 *
4 * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
5 */
6
7use anyhow::Result;
8use clap::{Command, Parser, Subcommand};
9use clap_complete::shells::Shell;
10
11use super::GlobalArgs;
12
13pub mod dcf;
14pub mod ef;
15pub mod offsets;
16
17#[derive(Subcommand, Debug)]
18#[command(name = "Builds accessory bv graph data structures (e.g., offsets, ef, etc.).")]
19/// Check coherence of files.
20pub enum SubCommands {
21    Ef(ef::CliArgs),
22    Dcf(dcf::CliArgs),
23    Offsets(offsets::CliArgs),
24    Complete(CompleteArgs),
25}
26
27/// Generates shell completions. Use with `source <(webgraph build completions $SHELL)`.
28#[derive(Parser, Debug)]
29pub struct CompleteArgs {
30    shell: Shell,
31}
32
33pub fn main(
34    global_args: GlobalArgs,
35    subcommand: SubCommands,
36    mut top_command: Command,
37) -> Result<()> {
38    match subcommand {
39        SubCommands::Ef(args) => ef::main(global_args, args),
40        SubCommands::Dcf(args) => dcf::main(global_args, args),
41        SubCommands::Offsets(args) => offsets::main(global_args, args),
42        SubCommands::Complete(args) => {
43            clap_complete::generate(
44                args.shell,
45                &mut top_command,
46                "webgraph",
47                &mut std::io::stdout(),
48            );
49            Ok(())
50        }
51    }
52}