pma_cli/
command.rs

1use clap::{Parser, ValueHint};
2
3#[derive(Debug, Parser)]
4#[clap(
5    name = env!("CARGO_PKG_NAME"),
6    version = env!("CARGO_PKG_VERSION"),
7    author = env!("CARGO_PKG_AUTHORS"),
8    about = env!("CARGO_PKG_DESCRIPTION"),
9)]
10pub struct Opt {
11    /// Location of phpmyadmin
12    #[clap(short, long, value_hint = ValueHint::Url)]
13    pub url: String,
14
15    /// Language of phpmyadmin
16    #[clap(short, long, default_value = "ja")]
17    pub lang: String,
18
19    #[clap(subcommand)]
20    pub command: Command,
21}
22
23#[derive(Debug, Parser)]
24pub enum Command {
25    /// Export the specified tables.
26    Export {
27        /// Export the specified table names.
28        tables: Vec<String>,
29
30        #[clap(flatten)]
31        export_option: ExportOption,
32    },
33    /// Export all tables.
34    ExportAll {
35        /// Export table names that match the specified regex.
36        #[clap(short, long, value_name = "regex")]
37        filter_table: Option<String>,
38
39        #[clap(flatten)]
40        export_option: ExportOption,
41    },
42}
43
44#[derive(Debug, Parser)]
45pub struct ExportOption {
46    /// Database name
47    #[clap(long, help_heading = "Required")]
48    pub db: String,
49
50    /// Include all data.
51    #[clap(short, long, group = "include_data", default_value = "false")]
52    pub all_data: bool,
53
54    /// Include data in the specified table names.
55    #[clap(short, long, group = "include_data", value_name = "table name")]
56    pub data: Option<Vec<String>>,
57
58    /// Include data from a table with conditions matching the specified prefix.
59    #[clap(long, group = "include_data", value_name = "table name prefix")]
60    pub data_prefix: Option<String>,
61
62    /// Destination of exported data.
63    #[clap(short, long, default_value = "./")]
64    pub output: String,
65
66    /// Separate exported data.
67    #[clap(short, long, default_value = "false")]
68    pub separate_files: bool,
69
70    /// Add `CREATE DATABASE` command.
71    #[clap(short, long, default_value = "false")]
72    pub create_database: bool,
73}