diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c88f57c..0d61c6a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- add `-d`, `--directory` options to set starting working directory ### Changed - changed hotkeys for selecting stage/workdir (**[w] / [s]** now to change between workdir and stage) and added hotkeys (`[1234]`) to switch to tabs directly ([#92](https://github.com/extrawurst/gitui/issues/92)) diff --git a/src/main.rs b/src/main.rs index 22db83e0..d066ce16 100644 --- a/src/main.rs +++ b/src/main.rs @@ -234,6 +234,13 @@ fn process_cmdline() -> Result<()> { .help("Stores logging output into a cache directory") .short("l") .long("logging"), + ) + .arg( + Arg::with_name("directory") + .help("Set the working directory") + .short("d") + .long("directory") + .takes_value(true), ); let arg_matches = app.get_matches(); @@ -241,6 +248,12 @@ fn process_cmdline() -> Result<()> { setup_logging()?; } + if arg_matches.is_present("directory") { + let directory = + arg_matches.value_of("directory").unwrap_or("."); + env::set_current_dir(directory)?; + } + Ok(()) }