• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 6299724219

25 Sep 2023 12:58PM UTC coverage: 77.81% (+0.5%) from 77.275%
6299724219

push

github

chubei
fix: Add `BINDGEN_EXTRA_CLANG_ARGS` to cross compile rocksdb

50223 of 64546 relevant lines covered (77.81%)

148909.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.38
/dozer-cli/src/cli/types.rs
1
use clap::{Args, Parser, Subcommand};
2

3
use super::helper::{DESCRIPTION, LOGO};
4

5
#[cfg(feature = "cloud")]
6
use crate::cli::cloud::Cloud;
7
use dozer_types::{
8
    constants::{DEFAULT_CONFIG_PATH_PATTERNS, LOCK_FILE},
9
    serde_json,
10
};
11

12
#[derive(Parser, Debug)]
×
13
#[command(author, version, name = "dozer")]
14
#[command(
15
    about = format!("{} \n {}", LOGO, DESCRIPTION),
16
    long_about = None,
17
)]
18
pub struct Cli {
19
    #[arg(
20
        global = true,
21
        short = 'c',
22
        long = "config-path",
23
        default_values = DEFAULT_CONFIG_PATH_PATTERNS
24
    )]
25
    pub config_paths: Vec<String>,
×
26
    #[arg(global = true, long, hide = true)]
27
    pub config_token: Option<String>,
28
    #[arg(global = true, long = "enable-progress")]
29
    pub enable_progress: bool,
×
30
    #[arg(global = true, long, value_parser(parse_config_override))]
31
    pub config_overrides: Vec<(String, serde_json::Value)>,
×
32

33
    #[arg(global = true, long = "ignore-pipe")]
34
    pub ignore_pipe: bool,
×
35
    #[clap(subcommand)]
36
    pub cmd: Commands,
37
}
38

39
fn parse_config_override(
3✔
40
    arg: &str,
3✔
41
) -> Result<(String, serde_json::Value), Box<dyn std::error::Error + Send + Sync + 'static>> {
3✔
42
    let mut split = arg.split('=');
3✔
43
    let pointer = split.next().ok_or("missing json pointer")?;
3✔
44
    let value = split.next().ok_or("missing json value")?;
3✔
45
    Ok((pointer.to_string(), serde_json::from_str(value)?))
3✔
46
}
3✔
47

48
#[derive(Debug, Subcommand)]
×
49
pub enum Commands {
50
    #[command(
51
        about = "Initialize an app using a template",
52
        long_about = "Initialize dozer app workspace. It will generate dozer configuration and \
53
            folder structure."
54
    )]
55
    Init,
56
    #[command(about = "Edit code interactively")]
57
    Live(Live),
58
    #[command(
59
        about = "Clean home directory",
60
        long_about = "Clean home directory. It removes all data, schemas and other files in app \
61
            directory"
62
    )]
63
    Clean,
64
    #[command(
65
        about = "Initialize and lock schema definitions. Once initialized, schemas cannot \
66
            be changed"
67
    )]
68
    Build(Build),
69
    #[command(about = "Run App or Api Server")]
70
    Run(Run),
71
    #[command(
72
        about = "Show Sources",
73
        long_about = "Show available tables schemas in external sources"
74
    )]
75
    Connectors(ConnectorCommand),
76
    #[command(about = "Change security settings")]
77
    Security(Security),
78
    #[cfg(feature = "cloud")]
79
    #[command(about = "Deploy cloud applications")]
80
    Cloud(Cloud),
81
}
82

83
#[derive(Debug, Args)]
×
84
#[command(args_conflicts_with_subcommands = true)]
85
pub struct Live {
86
    #[arg(long, hide = true)]
87
    pub disable_live_ui: bool,
×
88
}
89

90
#[derive(Debug, Args)]
×
91
#[command(args_conflicts_with_subcommands = true)]
92
pub struct Build {
93
    #[arg(help = format!("Require that {LOCK_FILE} is up-to-date"), long = "locked")]
94
    pub locked: bool,
×
95
    #[arg(short = 'f')]
96
    pub force: Option<Option<String>>,
97
}
98

99
#[derive(Debug, Args)]
×
100
pub struct Run {
101
    #[arg(help = format!("Require that {LOCK_FILE} is up-to-date"), long = "locked")]
102
    pub locked: bool,
×
103
    #[command(subcommand)]
104
    pub command: Option<RunCommands>,
105
}
106

107
#[derive(Debug, Subcommand)]
×
108
pub enum RunCommands {
109
    #[command(
110
        about = "Run app instance",
111
        long_about = "Run app instance. App instance is responsible for ingesting data and \
112
            passing it through pipeline"
113
    )]
114
    App,
115
    #[command(
116
        about = "Run api instance",
117
        long_about = "Run api instance. Api instance runs server which creates access to \
118
            API endpoints through REST and GRPC (depends on configuration)"
119
    )]
120
    Api,
121
}
122

123
#[derive(Debug, Args)]
×
124
pub struct Security {
125
    #[command(subcommand)]
126
    pub command: SecurityCommands,
127
}
128

129
#[derive(Debug, Subcommand)]
×
130
pub enum SecurityCommands {
131
    #[command(
132
        author,
133
        version,
134
        about = "Generate master token",
135
        long_about = "Master Token can be used to create other run time tokens \
136
        that encapsulate different permissions."
137
    )]
138
    GenerateToken,
139
}
140

141
#[derive(Debug, Args)]
×
142
#[command(args_conflicts_with_subcommands = true)]
143
pub struct Deploy {
144
    pub target_url: String,
×
145
    #[arg(short = 'u')]
146
    pub username: Option<String>,
147
    #[arg(short = 'p')]
148
    pub password: Option<String>,
149
}
150

151
#[derive(Debug, Args)]
×
152
pub struct ConnectorCommand {
153
    #[arg(short = 'f')]
154
    pub filter: Option<String>,
155
}
156

157
#[cfg(test)]
158
mod tests {
159
    use dozer_types::serde_json;
160

161
    #[test]
1✔
162
    fn test_parse_config_override_string() {
1✔
163
        let arg = "/app=\"abc\"";
1✔
164
        let result = super::parse_config_override(arg).unwrap();
1✔
165
        assert_eq!(result.0, "/app");
1✔
166
        assert_eq!(result.1, serde_json::Value::String("abc".to_string()));
1✔
167
    }
1✔
168

169
    #[test]
1✔
170
    fn test_parse_config_override_number() {
1✔
171
        let arg = "/app=123";
1✔
172
        let result = super::parse_config_override(arg).unwrap();
1✔
173
        assert_eq!(result.0, "/app");
1✔
174
        assert_eq!(result.1, serde_json::Value::Number(123.into()));
1✔
175
    }
1✔
176

177
    #[test]
1✔
178
    fn test_parse_config_override_object() {
1✔
179
        let arg = "/app={\"a\": 1}";
1✔
180
        let result = super::parse_config_override(arg).unwrap();
1✔
181
        assert_eq!(result.0, "/app");
1✔
182
        assert_eq!(
1✔
183
            result.1,
1✔
184
            serde_json::json!({
1✔
185
                "a": 1
1✔
186
            })
1✔
187
        );
1✔
188
    }
1✔
189
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc