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