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

getdozer / dozer / 5867589746

pending completion
5867589746

Pull #1858

github

supergi01
resolve fmt checks(2)
Pull Request #1858: feat: Implement graph for dozer-live ui

419 of 419 new or added lines in 15 files covered. (100.0%)

46001 of 59761 relevant lines covered (76.97%)

52384.12 hits per line

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

53.97
/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;
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, short = 'p', long = "enable-progress")]
26
    pub enable_progress: Option<Option<String>>,
×
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,
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 Build {
83
    #[arg(short = 'f')]
84
    pub force: Option<Option<String>>,
85
}
×
86

87
#[derive(Debug, Args)]
×
88
pub struct Run {
89
    #[command(subcommand)]
90
    pub command: RunCommands,
91
}
×
92

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

109
#[derive(Debug, Args)]
×
110
pub struct Security {
111
    #[command(subcommand)]
112
    pub command: SecurityCommands,
113
}
×
114

115
#[derive(Debug, Subcommand)]
×
116
pub enum SecurityCommands {
117
    #[command(
118
        author,
119
        version,
120
        about = "Generate master token",
121
        long_about = "Master Token can be used to create other run time tokens \
122
        that encapsulate different permissions."
123
    )]
124
    GenerateToken,
125
}
×
126

127
#[derive(Debug, Args)]
×
128
#[command(args_conflicts_with_subcommands = true)]
×
129
pub struct Deploy {
130
    pub target_url: String,
×
131
    #[arg(short = 'u')]
132
    pub username: Option<String>,
133
    #[arg(short = 'p')]
134
    pub password: Option<String>,
135
}
×
136

137
#[derive(Debug, Args)]
×
138
pub struct ConnectorCommand {
139
    #[arg(short = 'f')]
140
    pub filter: Option<String>,
141
}
142

143
#[cfg(test)]
×
144
mod tests {
×
145
    #[test]
1✔
146
    fn test_parse_config_override_string() {
1✔
147
        let arg = "/app=\"abc\"";
1✔
148
        let result = super::parse_config_override(arg).unwrap();
1✔
149
        assert_eq!(result.0, "/app");
1✔
150
        assert_eq!(result.1, serde_json::Value::String("abc".to_string()));
1✔
151
    }
1✔
152

×
153
    #[test]
1✔
154
    fn test_parse_config_override_number() {
1✔
155
        let arg = "/app=123";
1✔
156
        let result = super::parse_config_override(arg).unwrap();
1✔
157
        assert_eq!(result.0, "/app");
1✔
158
        assert_eq!(result.1, serde_json::Value::Number(123.into()));
1✔
159
    }
1✔
160

×
161
    #[test]
1✔
162
    fn test_parse_config_override_object() {
1✔
163
        let arg = "/app={\"a\": 1}";
1✔
164
        let result = super::parse_config_override(arg).unwrap();
1✔
165
        assert_eq!(result.0, "/app");
1✔
166
        assert_eq!(
1✔
167
            result.1,
1✔
168
            serde_json::json!({
1✔
169
                "a": 1
1✔
170
            })
1✔
171
        );
1✔
172
    }
1✔
173
}
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