Resolve relative paths in yabridgectl

This commit is contained in:
Robbert van der Helm
2020-09-22 23:15:51 +02:00
parent 086ee0c09f
commit 4c89558457
2 changed files with 28 additions and 7 deletions
+7
View File
@@ -6,6 +6,13 @@ 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]
### yabridgectl
- Resolve relative paths when adding plugin directories or when changing
settings.
## [1.6.0] - 2020-09-17
### Added
+21 -7
View File
@@ -121,13 +121,24 @@ fn main() -> Result<()> {
)
.get_matches();
// We're calling canonicalize when adding and setting paths since relative paths would cause
// some weird behaviour. There's no built-in way to make relative paths absoltue without
// resolving symlinks, but I don't think this will cause any issues.
//
// https://github.com/rust-lang/rust/issues/59117
match matches.subcommand() {
("add", Some(options)) => {
actions::add_directory(&mut config, options.value_of_t_or_exit("path"))
}
("rm", Some(options)) => {
actions::remove_directory(&mut config, &options.value_of_t_or_exit::<PathBuf>("path"))
}
("add", Some(options)) => actions::add_directory(
&mut config,
options
.value_of_t_or_exit::<PathBuf>("path")
.canonicalize()?,
),
("rm", Some(options)) => actions::remove_directory(
&mut config,
&options
.value_of_t_or_exit::<PathBuf>("path")
.canonicalize()?,
),
("list", _) => actions::list_directories(&config),
("status", _) => actions::show_status(&config),
("set", Some(options)) => actions::set_settings(
@@ -136,7 +147,10 @@ fn main() -> Result<()> {
method: options.value_of("method"),
// We've already verified that the path is valid, so we should only be getting
// errors for missing arguments
path: options.value_of_t("path").ok(),
path: options
.value_of_t::<PathBuf>("path")
.ok()
.and_then(|path| path.canonicalize().ok()),
},
),
("sync", Some(options)) => actions::do_sync(