Skip to main content

lance_tools/
cli.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright The Lance Authors
3
4use clap::{Args, Parser, Subcommand};
5use lance_core::Result;
6
7#[derive(Parser, Debug)]
8#[command(
9    name = "lance-tools",
10    about = "Tools for interacting with Lance files and tables",
11    version
12)]
13pub struct LanceToolsArgs {
14    /// Subcommand to run
15    #[command(subcommand)]
16    command: LanceToolsCommand,
17}
18
19#[derive(Subcommand, Debug)]
20pub enum LanceToolsCommand {
21    /// Commands for interacting with Lance files.
22    File(LanceFileArgs),
23}
24
25#[derive(Parser, Debug)]
26pub struct LanceFileArgs {
27    #[command(subcommand)]
28    command: LanceFileCommand,
29}
30
31#[derive(Subcommand, Debug)]
32pub enum LanceFileCommand {
33    /// Display Lance file metadata.
34    Meta(LanceFileMetaArgs),
35}
36
37#[derive(Args, Debug)]
38pub struct LanceFileMetaArgs {
39    // The Lance file to examine.
40    #[arg(short = 's', long, value_name = "source")]
41    pub(crate) source: String,
42}
43
44impl LanceToolsArgs {
45    pub async fn run(&self, writer: impl std::io::Write) -> Result<()> {
46        match &self.command {
47            LanceToolsCommand::File(args) => match &args.command {
48                LanceFileCommand::Meta(args) => crate::meta::show_file_meta(writer, args).await,
49            },
50        }
51    }
52}