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

getdozer / dozer / 5961262257

24 Aug 2023 08:21AM UTC coverage: 75.714% (-0.5%) from 76.217%
5961262257

push

github

web-flow
fix: Put live cache in temporary directory (#1906)

4 of 4 new or added lines in 1 file covered. (100.0%)

47019 of 62101 relevant lines covered (75.71%)

89119.16 hits per line

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

62.96
/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::{constants::DEFAULT_CONFIG_PATH_PATTERNS, serde_json};
8

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

30
    #[arg(global = true, long = "ignore-pipe")]
31
    pub ignore_pipe: bool,
×
32
    #[clap(subcommand)]
33
    pub cmd: Option<Commands>,
34
}
35

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

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

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

87
#[derive(Debug, Args)]
×
88
#[command(args_conflicts_with_subcommands = true)]
89
pub struct Build {
90
    #[arg(short = 'f')]
91
    pub force: Option<Option<String>>,
92
}
93

94
#[derive(Debug, Args)]
×
95
pub struct Run {
96
    #[command(subcommand)]
97
    pub command: RunCommands,
98
}
99

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

116
#[derive(Debug, Args)]
×
117
pub struct Security {
118
    #[command(subcommand)]
119
    pub command: SecurityCommands,
120
}
121

122
#[derive(Debug, Subcommand)]
×
123
pub enum SecurityCommands {
124
    #[command(
125
        author,
126
        version,
127
        about = "Generate master token",
128
        long_about = "Master Token can be used to create other run time tokens \
129
        that encapsulate different permissions."
130
    )]
131
    GenerateToken,
132
}
133

134
#[derive(Debug, Args)]
×
135
#[command(args_conflicts_with_subcommands = true)]
136
pub struct Deploy {
137
    pub target_url: String,
×
138
    #[arg(short = 'u')]
139
    pub username: Option<String>,
140
    #[arg(short = 'p')]
141
    pub password: Option<String>,
142
}
143

144
#[derive(Debug, Args)]
×
145
pub struct ConnectorCommand {
146
    #[arg(short = 'f')]
147
    pub filter: Option<String>,
148
}
149

150
#[cfg(test)]
151
mod tests {
152
    use dozer_types::serde_json;
×
153

×
154
    #[test]
1✔
155
    fn test_parse_config_override_string() {
1✔
156
        let arg = "/app=\"abc\"";
1✔
157
        let result = super::parse_config_override(arg).unwrap();
1✔
158
        assert_eq!(result.0, "/app");
1✔
159
        assert_eq!(result.1, serde_json::Value::String("abc".to_string()));
1✔
160
    }
1✔
161

×
162
    #[test]
1✔
163
    fn test_parse_config_override_number() {
1✔
164
        let arg = "/app=123";
1✔
165
        let result = super::parse_config_override(arg).unwrap();
1✔
166
        assert_eq!(result.0, "/app");
1✔
167
        assert_eq!(result.1, serde_json::Value::Number(123.into()));
1✔
168
    }
1✔
169

×
170
    #[test]
1✔
171
    fn test_parse_config_override_object() {
1✔
172
        let arg = "/app={\"a\": 1}";
1✔
173
        let result = super::parse_config_override(arg).unwrap();
1✔
174
        assert_eq!(result.0, "/app");
1✔
175
        assert_eq!(
1✔
176
            result.1,
1✔
177
            serde_json::json!({
1✔
178
                "a": 1
1✔
179
            })
1✔
180
        );
1✔
181
    }
1✔
182
}
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