1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use clap::{Parser, ValueHint};

#[derive(Debug, Parser)]
pub struct Opt {
    /// Location of phpmyadmin
    #[clap(short, long, value_hint = ValueHint::Url)]
    pub url: String,

    /// Language of phpmyadmin
    #[clap(short, long, default_value = "ja")]
    pub lang: String,

    #[clap(subcommand)]
    pub command: Command,
}

#[derive(Debug, Parser)]
pub enum Command {
    /// Export the specified tables.
    Export {
        /// Export the specified table names.
        tables: Vec<String>,

        #[clap(flatten)]
        export_option: ExportOption,
    },
    /// Export all tables.
    ExportAll {
        #[clap(flatten)]
        export_option: ExportOption,
    },
}

#[derive(Debug, Parser)]
pub struct ExportOption {
    /// Database name
    #[clap(long, help_heading = "Required")]
    pub db: String,

    /// Include all data.
    #[clap(short, long, group = "include_data", default_value = "false")]
    pub all_data: bool,

    /// Include data in the specified table names.
    #[clap(short, long, group = "include_data", value_name = "table name")]
    pub data: Option<Vec<String>>,

    /// Include data from a table with conditions matching the specified prefix.
    #[clap(long, group = "include_data", value_name = "table name prefix")]
    pub data_prefix: Option<String>,

    /// Destination of exported data.
    #[clap(short, long, default_value = "./")]
    pub output: String,

    /// Separate exported data.
    #[clap(short, long, default_value = "false")]
    pub separate_files: bool,
}