add --directory option (#104)

closes #73
This commit is contained in:
A. Carscadden 2020-06-04 06:33:36 -04:00 committed by GitHub
parent bec1fb939a
commit 702c49a147
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -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))

View file

@ -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(())
}