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

getdozer / dozer / 5852729195

pending completion
5852729195

push

github

web-flow
load config from stdin (#1839)

* merge fn

* fix lint errors

* cargo fmt

* combine stdin, file load

* wip: load config from stdin

* --ignore-pipe

* is_err

* typo

* empty commit revert

* enable ->ignore

* ignore pipe logic

* load-config-from-stdin

* load-config-from-stdin

* load-config-from-stdin

* resolved-changes

38 of 38 new or added lines in 5 files covered. (100.0%)

45595 of 62625 relevant lines covered (72.81%)

39134.84 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, long, value_parser(parse_config_override))]
26
    pub config_overrides: Vec<(String, serde_json::Value)>,
×
27

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

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

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

78
#[derive(Debug, Args)]
×
79
#[command(args_conflicts_with_subcommands = true)]
80
pub struct Build {
81
    #[arg(short = 'f')]
×
82
    pub force: Option<Option<String>>,
83
}
84

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

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

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

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

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

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

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

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

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

© 2026 Coveralls, Inc