From 702c49a147ce06791def0ea3f10e3122fd7f942f Mon Sep 17 00:00:00 2001 From: "A. Carscadden" <7132621+alistaircarscadden@users.noreply.github.com> Date: Thu, 4 Jun 2020 06:33:36 -0400 Subject: [PATCH] add --directory option (#104) closes #73 --- CHANGELOG.md | 1 + src/main.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c88f57c34..0d61c6a60a 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 22db83e001..d066ce1638 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(()) }