A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

cli: add run subcommand and remove dependency on external deno command

+37 -7
+1
cli/src/cmd/mod.rs
··· 1 1 pub mod community; 2 2 pub mod repl; 3 + pub mod run; 3 4 pub mod scan; 4 5 pub mod start; 5 6 pub mod webui;
+3 -2
cli/src/cmd/repl.rs
··· 5 5 } 6 6 7 7 pub fn repl() { 8 - let handle = thread::spawn(|| { 9 - deno::cli(svec!["deno", "repl", "-A"]); 8 + let handle = thread::spawn(|| match deno::cli(svec!["deno", "repl", "-A"]) { 9 + Ok(_) => {} 10 + Err(_) => {} 10 11 }); 11 12 handle.join().unwrap(); 12 13 }
+9
cli/src/cmd/run.rs
··· 1 + use std::{ffi::OsString, thread}; 2 + 3 + pub fn run(args: Vec<OsString>) { 4 + let handle = thread::spawn(move || match deno::cli(args) { 5 + Ok(_) => {} 6 + Err(_) => {} 7 + }); 8 + handle.join().unwrap(); 9 + }
+1 -2
cli/src/lib.rs
··· 27 27 } 28 28 29 29 pub fn wait_for_rockboxd(port: u32, timeout: Option<u32>) -> Result<(), Error> { 30 - setup_pkgx()?; 31 30 let cmd = format!( 32 - "pkgx deno run -A npm:wait-port localhost:{} -t {}", 31 + "rockbox run -A npm:wait-port localhost:{} -t {}", 33 32 port, 34 33 timeout.unwrap_or(60) * 1000 35 34 );
+23 -1
cli/src/main.rs
··· 1 + use std::ffi::OsString; 2 + 1 3 use anyhow::Error; 2 4 use clap::{arg, Command}; 3 5 use owo_colors::OwoColorize; 4 6 5 - use cmd::{community::*, repl::*, scan::*, start::*, webui::*}; 7 + use cmd::{community::*, repl::*, run::*, scan::*, start::*, webui::*}; 6 8 7 9 pub mod cmd; 8 10 ··· 46 48 .about("Start the Rockbox REPL") 47 49 .visible_alias("shell"), 48 50 ) 51 + .subcommand( 52 + Command::new("run") 53 + .arg(arg!(<FILE> "JavaScript or TypeScript file to run")) 54 + .about("Run a JavaScript or TypeScript program") 55 + .visible_alias("x"), 56 + ) 49 57 } 50 58 51 59 #[tokio::main] 52 60 async fn main() -> Result<(), Error> { 61 + let args = std::env::args().collect::<Vec<String>>(); 62 + if args.len() > 1 && args[1] == "run" { 63 + let _args = args 64 + .into_iter() 65 + .map(|s| match s.as_str() { 66 + "rockbox" => "deno".into(), 67 + _ => s.into(), 68 + }) 69 + .collect::<Vec<OsString>>(); 70 + 71 + run(_args); 72 + return Ok(()); 73 + } 74 + 53 75 let matches = cli().get_matches(); 54 76 55 77 match matches.subcommand() {
-2
crates/mpd/src/handlers/system.rs
··· 1 - use std::os::unix::thread; 2 - 3 1 use anyhow::Error; 4 2 use tokio::sync::mpsc::Sender; 5 3