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

getdozer / dozer / 4020902227

pending completion
4020902227

Pull #743

github

GitHub
Merge 57279c6b6 into a12da35a5
Pull Request #743: Chore clippy fix

165 of 165 new or added lines in 60 files covered. (100.0%)

23638 of 35485 relevant lines covered (66.61%)

38417.79 hits per line

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

0.0
/dozer-orchestrator/src/cli/repl/editor.rs
1
use std::sync::atomic::AtomicBool;
2
use std::sync::Arc;
3

4
use crate::cli::repl::helper::get_commands;
5
use crate::cli::{list_sources, load_config};
6
use crate::errors::{CliError, OrchestrationError};
7
use crate::utils::get_repl_history_path;
8

9
use super::helper::{ConfigureHelper, DozerCmd, TabEventHandler};
10
use dozer_types::log::{debug, error, info};
11
use rustyline::error::ReadlineError;
12
use rustyline::Editor;
13
use rustyline::{EventHandler, KeyEvent};
14

15
pub fn configure(config_path: String, running: Arc<AtomicBool>) -> Result<(), OrchestrationError> {
×
16
    let config = load_config(config_path.clone())?;
×
17

18
    let h = ConfigureHelper {
×
19
        hints: super::helper::hints(),
×
20
    };
×
21
    let mut rl = Editor::<ConfigureHelper>::new()
×
22
        .map_err(|e| OrchestrationError::CliError(CliError::ReadlineError(e)))?;
×
23
    rl.set_helper(Some(h));
×
24
    rl.bind_sequence(
×
25
        KeyEvent::from('\t'),
×
26
        EventHandler::Conditional(Box::new(TabEventHandler)),
×
27
    );
×
28
    let history_path = get_repl_history_path(&config);
×
29

×
30
    if rl.load_history(history_path.as_path()).is_err() {
×
31
        debug!("No previous history file found.");
×
32
    }
×
33
    loop {
×
34
        let readline = rl.readline("dozer> ");
×
35
        match readline {
×
36
            Ok(line) => {
×
37
                rl.add_history_entry(line.as_str());
×
38
                if !line.is_empty() && !execute(&line, &config_path, running.clone())? {
×
39
                    break;
×
40
                }
×
41
            }
42
            Err(ReadlineError::Interrupted) => {
43
                info!("Exiting..");
×
44
                break;
×
45
            }
46
            Err(ReadlineError::Eof) => {
47
                break;
×
48
            }
49
            Err(err) => {
×
50
                error!("Error: {:?}", err);
×
51
                break;
×
52
            }
53
        }
54
    }
55
    rl.save_history(&history_path)
×
56
        .map_err(|e| OrchestrationError::CliError(CliError::ReadlineError(e)))?;
×
57
    Ok(())
×
58
}
×
59

60
fn execute(
×
61
    cmd: &str,
×
62
    config_path: &String,
×
63
    running: Arc<AtomicBool>,
×
64
) -> Result<bool, OrchestrationError> {
×
65
    let cmd_map = get_commands();
×
66
    if let Some((_, dozer_cmd)) = cmd_map.iter().find(|(s, _)| s.to_string() == *cmd) {
×
67
        match dozer_cmd {
×
68
            DozerCmd::Help => {
69
                print_help();
×
70
                Ok(true)
×
71
            }
72
            DozerCmd::ShowSources => {
73
                list_sources(config_path)?;
×
74
                Ok(true)
×
75
            }
76
            DozerCmd::Sql => {
77
                super::sql::editor(config_path, running)?;
×
78
                Ok(true)
×
79
            }
80
            DozerCmd::Exit => Ok(false),
×
81
            DozerCmd::TestConnections => todo!(),
×
82
        }
83
    } else {
84
        error!("Unknown command: {}", cmd);
×
85
        Ok(true)
×
86
    }
87
}
×
88

89
fn print_help() {
×
90
    use std::println as info;
×
91
    info!("Commands:");
×
92
    info!();
×
93
    for (c, _) in get_commands() {
×
94
        info!("{c}");
×
95
    }
×
96
    info!();
×
97
}
×
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