mirror of
https://github.com/wez/wezterm.git
synced 2025-01-04 19:54:56 +03:00
Allow specifying the gui system via the cli
This commit is contained in:
parent
b0c2704118
commit
8c821bc9e6
@ -35,6 +35,26 @@ impl GuiSelection {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: find or build a proc macro for this
|
||||
pub fn variants() -> Vec<&'static str> {
|
||||
vec!["Glutin", "X11"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for GuiSelection {
|
||||
type Err = Error;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s.to_lowercase().as_ref() {
|
||||
"glutin" => Ok(GuiSelection::Glutin),
|
||||
"x11" => Ok(GuiSelection::X11),
|
||||
_ => Err(format_err!(
|
||||
"{} is not a valid GuiSelection variant, possible values are {:?}",
|
||||
s,
|
||||
GuiSelection::variants()
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait GuiSystem {
|
||||
|
14
src/main.rs
14
src/main.rs
@ -20,7 +20,7 @@ mod futurecore;
|
||||
mod gliumwindows;
|
||||
mod guiloop;
|
||||
mod opengl;
|
||||
|
||||
use crate::guiloop::GuiSelection;
|
||||
use crate::guiloop::GuiSystem;
|
||||
|
||||
mod font;
|
||||
@ -73,6 +73,15 @@ struct Opt {
|
||||
#[structopt(short = "n")]
|
||||
skip_config: bool,
|
||||
|
||||
#[structopt(
|
||||
long = "gui-system",
|
||||
raw(
|
||||
possible_values = "&GuiSelection::variants()",
|
||||
case_insensitive = "true"
|
||||
)
|
||||
)]
|
||||
gui_system: Option<GuiSelection>,
|
||||
|
||||
/// Instead of executing your shell, run PROG.
|
||||
/// For example: `wezterm -- bash -l` will spawn bash
|
||||
/// as if it were a login shell.
|
||||
@ -97,7 +106,8 @@ fn main() -> Result<(), Error> {
|
||||
None
|
||||
};
|
||||
|
||||
let gui = config.gui_system.new()?;
|
||||
let gui_system = opts.gui_system.unwrap_or(config.gui_system);
|
||||
let gui = gui_system.new()?;
|
||||
|
||||
spawn_window(&*gui, cmd, &config, &fontconfig)?;
|
||||
gui.run_forever(&config, &fontconfig)
|
||||
|
Loading…
Reference in New Issue
Block a user