diff options
author | Zach Day <zachdayz@gmail.com> | 2017-03-14 03:39:26 -0400 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2017-04-18 19:53:31 -0700 |
commit | 2bcd165a78cd20fb6eea0f1ddb0213da7fddf8a1 (patch) | |
tree | 829ba86e4dd881c43f57415a5c59a86bc9fc5f4f /src/cli.rs | |
parent | a3d00f01b136ce95613bb20db9e05bfe9342185b (diff) | |
download | alacritty-2bcd165a78cd20fb6eea0f1ddb0213da7fddf8a1.tar.gz alacritty-2bcd165a78cd20fb6eea0f1ddb0213da7fddf8a1.zip |
Add CLI arg for setting working directory
Resolves #478.
Diffstat (limited to 'src/cli.rs')
-rw-r--r-- | src/cli.rs | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -15,6 +15,7 @@ extern crate log; use clap::{Arg, App}; use index::{Line, Column}; use config::{Dimensions, Shell}; +use std::path::PathBuf; const DEFAULT_TITLE: &'static str = "Alacritty"; @@ -26,6 +27,7 @@ pub struct Options { pub title: String, pub log_level: log::LogLevelFilter, pub command: Option<Shell<'static>>, + pub working_dir: Option<PathBuf>, } impl Default for Options { @@ -37,6 +39,7 @@ impl Default for Options { title: DEFAULT_TITLE.to_owned(), log_level: log::LogLevelFilter::Warn, command: None, + working_dir: None, } } } @@ -75,6 +78,10 @@ impl Options { .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("command") .short("e") .multiple(true) @@ -117,6 +124,10 @@ impl Options { 3 | _ => options.log_level = log::LogLevelFilter::Trace } + if let Some(dir) = matches.value_of("working-directory") { + options.working_dir = Some(PathBuf::from(dir.to_string())); + } + if let Some(mut args) = matches.values_of("command") { // The following unwrap is guaranteed to succeed. // If 'command' exists it must also have a first item since |