diff --git a/src/main.rs b/src/main.rs index 7054287dc..7ced449e6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -101,17 +101,14 @@ struct Opt { /// as if it were a login shell. #[structopt(parse(from_os_str))] prog: Vec, + + /// Rather than running the terminal, run as the + /// multiplexer server. + #[structopt(long = "start-mux-server")] + start_mux_server: bool, } -fn main() -> Result<(), Error> { - let opts = Opt::from_args(); - let config = Arc::new(if opts.skip_config { - config::Config::default_config() - } else { - config::Config::load()? - }); - println!("Using configuration: {:#?}\nopts: {:#?}", config, opts); - +fn run_terminal_gui(config: Arc, opts: Opt) -> Result<(), Error> { let font_system = opts.font_system.unwrap_or(config.font_system); font_system.set_default(); @@ -133,6 +130,22 @@ fn main() -> Result<(), Error> { gui.run_forever() } +fn main() -> Result<(), Error> { + let opts = Opt::from_args(); + let config = Arc::new(if opts.skip_config { + config::Config::default_config() + } else { + config::Config::load()? + }); + println!("Using configuration: {:#?}\nopts: {:#?}", config, opts); + + if opts.start_mux_server { + server::listener::run_mux_server(config) + } else { + run_terminal_gui(config, opts) + } +} + fn spawn_tab( config: &Arc, cmd: Option>, diff --git a/src/server/listener.rs b/src/server/listener.rs index b03578a8c..9354b9863 100644 --- a/src/server/listener.rs +++ b/src/server/listener.rs @@ -1,6 +1,10 @@ +use crate::config::Config; +use crate::mux::Mux; use crate::server::{UnixListener, UnixStream}; use failure::Error; use std::io::{Read, Write}; +use std::rc::Rc; +use std::sync::Arc; pub trait SocketLike: Read + Write + Send {} @@ -31,3 +35,10 @@ impl Listener { } pub struct ClientSession {} + +pub fn run_mux_server(config: Arc) -> Result<(), Error> { + let mux = Rc::new(Mux::default()); + Mux::set_mux(&mux); + + Ok(()) +}