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
60
61
62
63
64
65
66
use crate::common::types::{DatabaseType, JsExtension};
use clap::Parser;

impl ToString for JsExtension {
    fn to_string(&self) -> String {
        match self {
            JsExtension::Ts => ".ts".to_string(),
            JsExtension::Js => ".js".to_string(),
        }
    }
}

#[derive(Parser, Debug, Clone)]
#[clap(author, version, about)]
pub struct Cli {
    /// Path to the Typescript or Javascript project
    #[clap(parse(from_os_str))]
    pub path: std::path::PathBuf,

    /// Javascript Extension
    #[clap(
    arg_enum,
    long,
    default_value_t=JsExtension::Ts
    )]
    pub ext: JsExtension,

    /// Type of primary database to connect
    #[clap(arg_enum, long)]
    pub db_type: Option<DatabaseType>,

    /// Primary DB host
    #[clap(long)]
    pub db_host: Option<String>,

    /// Primary DB Port
    #[clap(long)]
    pub db_port: Option<u16>,

    /// Primary DB user
    #[clap(long)]
    pub db_user: Option<String>,

    /// Primary DB pass
    #[clap(long)]
    pub db_pass: Option<String>,

    /// Primary DB database name
    #[clap(long)]
    pub db_name: Option<String>,

    /// Folder paths to ignore
    #[clap(long, parse(from_os_str), multiple_values = true)]
    pub ignore: Vec<std::path::PathBuf>,

    /// Path to the file based configuration
    #[clap(long, parse(from_os_str))]
    pub config: Option<std::path::PathBuf>,

    /// generate types of raw SQLs using default configuration
    #[clap(long, short)]
    pub generate_types: bool,

    #[clap(long, short)]
    pub message_format: Option<String>,
}