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