1mod export;
16pub mod export_v2;
17mod import;
18pub mod import_v2;
19pub(crate) mod path;
20pub(crate) mod retry;
21pub mod snapshot_storage;
22pub(crate) mod sql;
23mod storage_export;
24
25use clap::Subcommand;
26use client::DEFAULT_CATALOG_NAME;
27use common_error::ext::BoxedError;
28
29use crate::Tool;
30use crate::data::export::ExportCommand;
31use crate::data::export_v2::ExportV2Command;
32use crate::data::import::ImportCommand;
33use crate::data::import_v2::ImportV2Command;
34
35pub(crate) const COPY_PATH_PLACEHOLDER: &str = "<PATH/TO/FILES>";
36
37#[derive(Subcommand)]
39pub enum DataCommand {
40 Export(ExportCommand),
42 Import(ImportCommand),
44 #[clap(subcommand)]
46 ExportV2(ExportV2Command),
47 ImportV2(ImportV2Command),
49}
50
51impl DataCommand {
52 pub async fn build(&self) -> std::result::Result<Box<dyn Tool>, BoxedError> {
53 match self {
54 DataCommand::Export(cmd) => cmd.build().await,
55 DataCommand::Import(cmd) => cmd.build().await,
56 DataCommand::ExportV2(cmd) => cmd.build().await,
57 DataCommand::ImportV2(cmd) => cmd.build().await,
58 }
59 }
60}
61
62pub(crate) fn default_database() -> String {
63 format!("{DEFAULT_CATALOG_NAME}-*")
64}