Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09895aed authored by George Burgess's avatar George Burgess Committed by Gerrit Code Review
Browse files

Merge changes Ie23109b8,Ib6b8ed2a,I7a12a92d

* changes:
  use &str consistently
  upgrade to rustyline-10
  update to syslog-6
parents b0e32c86 6bb16d21
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2018"

[dependencies]
rustyline = "8.0"
rustyline = "10"
rustyline-derive = "0.4.0"
bt_topshim = { path = "../../topshim" }
btstack = { path = "../stack" }
+2 −2
Original line number Diff line number Diff line
@@ -286,9 +286,9 @@ impl CommandHandler {
    }

    /// Entry point for command and arguments
    pub fn process_cmd_line(&mut self, command: &String, args: &Vec<String>) {
    pub fn process_cmd_line(&mut self, command: &str, args: &Vec<String>) {
        // Ignore empty line
        match &command[..] {
        match command {
            "" => {}
            _ => match self.command_options.get(command) {
                Some(cmd) => {
+3 −3
Original line number Diff line number Diff line
@@ -178,16 +178,16 @@ impl AsyncEditor {
    pub(crate) fn new(
        command_rules: Vec<String>,
        client_context: Arc<Mutex<ClientContext>>,
    ) -> AsyncEditor {
    ) -> rustyline::Result<AsyncEditor> {
        let builder = Config::builder()
            .auto_add_history(true)
            .history_ignore_dups(true)
            .completion_type(CompletionType::List);
        let config = builder.build();
        let mut rl = rustyline::Editor::with_config(config);
        let mut rl = rustyline::Editor::with_config(config)?;
        let helper = BtHelper { command_rules, client_context };
        rl.set_helper(Some(helper));
        AsyncEditor { rl: Arc::new(Mutex::new(rl)) }
        Ok(AsyncEditor { rl: Arc::new(Mutex::new(rl)) })
    }

    /// Does async readline().
+7 −7
Original line number Diff line number Diff line
@@ -367,7 +367,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
                );
            }
            _ => {
                start_interactive_shell(handler, tx, rx, context).await;
                start_interactive_shell(handler, tx, rx, context).await?;
            }
        };
        return Result::Ok(());
@@ -379,7 +379,7 @@ async fn start_interactive_shell(
    tx: mpsc::Sender<ForegroundActions>,
    mut rx: mpsc::Receiver<ForegroundActions>,
    context: Arc<Mutex<ClientContext>>,
) {
) -> Result<(), Box<dyn std::error::Error>> {
    let command_rule_list = handler.get_command_rule_list().clone();
    let context_for_closure = context.clone();

@@ -387,9 +387,9 @@ async fn start_interactive_shell(

    // Async task to keep reading new lines from user
    let semaphore = semaphore_fg.clone();
    let editor = AsyncEditor::new(command_rule_list, context_for_closure)
        .map_err(|x| format!("creating async editor failed: {x}"))?;
    tokio::spawn(async move {
        let editor = AsyncEditor::new(command_rule_list, context_for_closure);

        loop {
            // Wait until ForegroundAction::Readline finishes its task.
            let permit = semaphore.acquire().await;
@@ -594,12 +594,11 @@ async fn start_interactive_shell(
                            None => break,
                        };

                        if cmd.eq("quit") {
                        if cmd == "quit" {
                            break 'readline;
                        }

                        handler.process_cmd_line(&String::from(cmd), &rest.to_vec());

                        handler.process_cmd_line(cmd, &rest.to_vec());
                        break;
                    }

@@ -613,4 +612,5 @@ async fn start_interactive_shell(
    semaphore_fg.close();

    print_info!("Client exiting");
    Ok(())
}
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ num-traits = "0.2"
protobuf = "2.0"
regex = "1.5"
serde_json = "1.0"
syslog = "4.0"
syslog = "6"
tokio = { version = "1.0", features = ["fs", "macros", "rt-multi-thread", "sync"] }

[build-dependencies]
Loading