aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/cli.rs
diff options
context:
space:
mode:
authormkosem <mattkosem@gmail.com>2019-09-24 13:43:54 -0400
committerChristian Duerr <contact@christianduerr.com>2019-09-24 19:43:54 +0200
commitc1f089970fd3d4b9137d07647f8cd028b2b5b3a9 (patch)
treeb8a8d9a62fa387f6b30e83b046f8beb4c521dbd7 /alacritty/src/cli.rs
parent856cddc8739c32d8bbfff72dd3692f49359142a9 (diff)
downloadr-alacritty-c1f089970fd3d4b9137d07647f8cd028b2b5b3a9.tar.gz
r-alacritty-c1f089970fd3d4b9137d07647f8cd028b2b5b3a9.tar.bz2
r-alacritty-c1f089970fd3d4b9137d07647f8cd028b2b5b3a9.zip
Add Xembed support
Fixes #631.
Diffstat (limited to 'alacritty/src/cli.rs')
-rw-r--r--alacritty/src/cli.rs196
1 files changed, 102 insertions, 94 deletions
diff --git a/alacritty/src/cli.rs b/alacritty/src/cli.rs
index 7c1554aa..d48ab4d7 100644
--- a/alacritty/src/cli.rs
+++ b/alacritty/src/cli.rs
@@ -32,6 +32,7 @@ pub struct Options {
pub position: Option<Delta<i32>>,
pub title: Option<String>,
pub class: Option<String>,
+ pub embed: Option<String>,
pub log_level: LevelFilter,
pub command: Option<Shell<'static>>,
pub working_dir: Option<PathBuf>,
@@ -49,6 +50,7 @@ impl Default for Options {
position: None,
title: None,
class: None,
+ embed: None,
log_level: LevelFilter::Warn,
command: None,
working_dir: None,
@@ -69,100 +71,104 @@ impl Options {
let mut options = Options::default();
- let matches = App::new(crate_name!())
- .version(version.as_str())
- .author(crate_authors!("\n"))
- .about(crate_description!())
- .arg(Arg::with_name("ref-test").long("ref-test").help("Generates ref test"))
- .arg(
- Arg::with_name("live-config-reload")
- .long("live-config-reload")
- .help("Enable automatic config reloading"),
- )
- .arg(
- Arg::with_name("no-live-config-reload")
- .long("no-live-config-reload")
- .help("Disable automatic config reloading")
- .conflicts_with("live-config-reload"),
- )
- .arg(
- Arg::with_name("print-events")
- .long("print-events")
- .help("Print all events to stdout"),
- )
- .arg(
- Arg::with_name("persistent-logging")
- .long("persistent-logging")
- .help("Keep the log file after quitting Alacritty"),
- )
- .arg(
- Arg::with_name("dimensions")
- .long("dimensions")
- .short("d")
- .value_names(&["columns", "lines"])
- .help(
- "Defines the window dimensions. Falls back to size specified by window \
- manager if set to 0x0 [default: 0x0]",
- ),
- )
- .arg(
- Arg::with_name("position")
- .long("position")
- .allow_hyphen_values(true)
- .value_names(&["x-pos", "y-pos"])
- .help(
- "Defines the window position. Falls back to position specified by window \
- manager if unset [default: unset]",
- ),
- )
- .arg(
- Arg::with_name("title")
- .long("title")
- .short("t")
- .takes_value(true)
- .help(&format!("Defines the window title [default: {}]", DEFAULT_NAME)),
- )
- .arg(
- Arg::with_name("class")
- .long("class")
- .takes_value(true)
- .help(&format!("Defines window class on Linux [default: {}]", DEFAULT_NAME)),
- )
- .arg(
- Arg::with_name("q")
- .short("q")
- .multiple(true)
- .conflicts_with("v")
- .help("Reduces the level of verbosity (the min level is -qq)"),
- )
- .arg(
- Arg::with_name("v")
- .short("v")
- .multiple(true)
- .conflicts_with("q")
- .help("Increases the level of verbosity (the max level is -vvv)"),
- )
- .arg(
- Arg::with_name("working-directory")
- .long("working-directory")
- .takes_value(true)
- .help("Start the shell in the specified working directory"),
- )
- .arg(Arg::with_name("config-file").long("config-file").takes_value(true).help(
- "Specify alternative configuration file [default: \
- $XDG_CONFIG_HOME/alacritty/alacritty.yml]",
- ))
- .arg(
- Arg::with_name("command")
- .long("command")
- .short("e")
- .multiple(true)
- .takes_value(true)
- .min_values(1)
- .allow_hyphen_values(true)
- .help("Command and args to execute (must be last argument)"),
- )
- .get_matches();
+ let matches =
+ App::new(crate_name!())
+ .version(version.as_str())
+ .author(crate_authors!("\n"))
+ .about(crate_description!())
+ .arg(Arg::with_name("ref-test").long("ref-test").help("Generates ref test"))
+ .arg(
+ Arg::with_name("live-config-reload")
+ .long("live-config-reload")
+ .help("Enable automatic config reloading"),
+ )
+ .arg(
+ Arg::with_name("no-live-config-reload")
+ .long("no-live-config-reload")
+ .help("Disable automatic config reloading")
+ .conflicts_with("live-config-reload"),
+ )
+ .arg(
+ Arg::with_name("print-events")
+ .long("print-events")
+ .help("Print all events to stdout"),
+ )
+ .arg(
+ Arg::with_name("persistent-logging")
+ .long("persistent-logging")
+ .help("Keep the log file after quitting Alacritty"),
+ )
+ .arg(
+ Arg::with_name("dimensions")
+ .long("dimensions")
+ .short("d")
+ .value_names(&["columns", "lines"])
+ .help(
+ "Defines the window dimensions. Falls back to size specified by \
+ window manager if set to 0x0 [default: 0x0]",
+ ),
+ )
+ .arg(
+ Arg::with_name("position")
+ .long("position")
+ .allow_hyphen_values(true)
+ .value_names(&["x-pos", "y-pos"])
+ .help(
+ "Defines the window position. Falls back to position specified by \
+ window manager if unset [default: unset]",
+ ),
+ )
+ .arg(
+ Arg::with_name("title")
+ .long("title")
+ .short("t")
+ .takes_value(true)
+ .help(&format!("Defines the window title [default: {}]", DEFAULT_NAME)),
+ )
+ .arg(
+ Arg::with_name("class").long("class").takes_value(true).help(&format!(
+ "Defines window class on Linux [default: {}]",
+ DEFAULT_NAME
+ )),
+ )
+ .arg(Arg::with_name("embed").long("embed").takes_value(true).help(
+ "Defines the X11 window ID (as a decimal integer) to embed Alacritty within",
+ ))
+ .arg(
+ Arg::with_name("q")
+ .short("q")
+ .multiple(true)
+ .conflicts_with("v")
+ .help("Reduces the level of verbosity (the min level is -qq)"),
+ )
+ .arg(
+ Arg::with_name("v")
+ .short("v")
+ .multiple(true)
+ .conflicts_with("q")
+ .help("Increases the level of verbosity (the max level is -vvv)"),
+ )
+ .arg(
+ Arg::with_name("working-directory")
+ .long("working-directory")
+ .takes_value(true)
+ .help("Start the shell in the specified working directory"),
+ )
+ .arg(Arg::with_name("config-file").long("config-file").takes_value(true).help(
+ "Specify alternative configuration file [default: \
+ $XDG_CONFIG_HOME/alacritty/alacritty.yml]",
+ ))
+ .arg(
+ Arg::with_name("command")
+ .long("command")
+ .short("e")
+ .multiple(true)
+ .takes_value(true)
+ .min_values(1)
+ .allow_hyphen_values(true)
+ .help("Command and args to execute (must be last argument)"),
+ )
+ .get_matches();
if matches.is_present("ref-test") {
options.ref_test = true;
@@ -200,6 +206,7 @@ impl Options {
options.class = matches.value_of("class").map(ToOwned::to_owned);
options.title = matches.value_of("title").map(ToOwned::to_owned);
+ options.embed = matches.value_of("embed").map(ToOwned::to_owned);
match matches.occurrences_of("q") {
0 => {},
@@ -250,6 +257,7 @@ impl Options {
config.window.dimensions = self.dimensions.unwrap_or(config.window.dimensions);
config.window.position = self.position.or(config.window.position);
config.window.title = self.title.or(config.window.title);
+ config.window.embed = self.embed.and_then(|embed| embed.parse().ok());
if let Some(class) = self.class {
let parts: Vec<_> = class.split(',').collect();