diff --git a/CHANGELOG.md b/CHANGELOG.md index ef834e90..701594f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### yabridgectl +- Yabridgectl's command line interface looks slightly differently again after + some dependency updates. The behavior remains the same. - Some outdated warning messages have been updated to make yabridge's current state. There are also additional warnings when detecting common installation issues. diff --git a/tools/yabridgectl/Cargo.lock b/tools/yabridgectl/Cargo.lock index 14b99ab8..37ac2eda 100644 --- a/tools/yabridgectl/Cargo.lock +++ b/tools/yabridgectl/Cargo.lock @@ -3,22 +3,60 @@ version = 3 [[package]] -name = "anyhow" -version = "1.0.57" +name = "anstream" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] [[package]] -name = "atty" -version = "0.2.14" +name = "anstyle" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", + "utf8parse", ] +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" + [[package]] name = "autocfg" version = "1.1.0" @@ -32,10 +70,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "cc" -version = "1.0.73" +name = "bitflags" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + +[[package]] +name = "cc" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -45,35 +92,52 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.1.18" +version = "4.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" +checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" dependencies = [ - "atty", - "bitflags", + "clap_builder", + "clap_derive", + "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" +dependencies = [ + "anstream", + "anstyle", "clap_lex", - "indexmap", - "lazy_static", + "once_cell", "strsim", - "termcolor", - "terminal_size 0.1.17", - "textwrap 0.15.0", + "terminal_size", +] + +[[package]] +name = "clap_derive" +version = "4.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "clap_lex" -version = "0.2.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" -dependencies = [ - "os_str_bytes", -] +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "clipboard-win" -version = "4.4.1" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f3e1238132dc01f081e1cbb9dace14e5ef4c3a51ee244bd982275fb514605db" +checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" dependencies = [ "error-code", "str-buf", @@ -81,21 +145,27 @@ dependencies = [ ] [[package]] -name = "colored" -version = "2.0.0" +name = "colorchoice" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "colored" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" dependencies = [ - "atty", + "is-terminal", "lazy_static", - "winapi", + "windows-sys", ] [[package]] name = "crossbeam-channel" -version = "0.5.4" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -103,9 +173,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -114,35 +184,24 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.8" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "lazy_static", - "memoffset", + "memoffset 0.9.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.8" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", - "lazy_static", -] - -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", ] [[package]] @@ -155,17 +214,6 @@ dependencies = [ "dirs-sys-next", ] -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -179,9 +227,9 @@ dependencies = [ [[package]] name = "either" -version = "1.6.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "endian-type" @@ -189,17 +237,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" -[[package]] -name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - [[package]] name = "errno" version = "0.3.2" @@ -208,7 +245,7 @@ checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -233,20 +270,20 @@ dependencies = [ [[package]] name = "fd-lock" -version = "3.0.5" +version = "3.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46e245f4c8ec30c6415c56cb132c07e69e74f1942f6b4a4061da748b49f486ca" +checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ "cfg-if", - "rustix 0.34.8", - "windows-sys 0.30.0", + "rustix 0.38.8", + "windows-sys", ] [[package]] name = "getrandom" -version = "0.2.6" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -255,9 +292,9 @@ dependencies = [ [[package]] name = "goblin" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572564d6cba7d09775202c8e7eebc4d534d5ae36578ab402fb21e182a0ac9505" +checksum = "0d6b4de4a8eb6c46a8c77e1d3be942cb9a8bf073c22374578e5ba4b08ed0ff68" dependencies = [ "log", "plain", @@ -265,19 +302,10 @@ dependencies = [ ] [[package]] -name = "hashbrown" -version = "0.11.2" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" @@ -285,31 +313,26 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" -[[package]] -name = "indexmap" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" -dependencies = [ - "autocfg", - "hashbrown", -] - -[[package]] -name = "io-lifetimes" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9448015e586b611e5d322f6703812bbca2f1e709d5773ecd38ddb4e3bb649504" - [[package]] name = "io-lifetimes" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi", "libc", - "windows-sys 0.48.0", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi", + "rustix 0.38.8", + "windows-sys", ] [[package]] @@ -341,20 +364,14 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libloading" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ "cfg-if", "winapi", ] -[[package]] -name = "linux-raw-sys" -version = "0.0.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" - [[package]] name = "linux-raw-sys" version = "0.3.8" @@ -362,13 +379,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] -name = "log" -version = "0.4.17" +name = "linux-raw-sys" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" @@ -385,6 +405,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + [[package]] name = "nibble_vec" version = "0.1.0" @@ -396,32 +425,32 @@ dependencies = [ [[package]] name = "nix" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" +checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cc", "cfg-if", "libc", - "memoffset", + "memoffset 0.6.5", ] [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi", "libc", ] [[package]] -name = "os_str_bytes" -version = "6.1.0" +name = "once_cell" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "plain" @@ -431,9 +460,9 @@ checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" [[package]] name = "proc-macro2" -version = "1.0.39" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -449,9 +478,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.18" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -468,21 +497,19 @@ dependencies = [ [[package]] name = "rayon" -version = "1.5.3" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.3" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -492,11 +519,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.13" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -519,32 +546,31 @@ dependencies = [ "winapi", ] -[[package]] -name = "rustix" -version = "0.34.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2079c267b8394eb529872c3cf92e181c378b41fea36e68130357b52493701d2e" -dependencies = [ - "bitflags", - "errno 0.2.8", - "io-lifetimes 0.6.1", - "libc", - "linux-raw-sys 0.0.46", - "winapi", -] - [[package]] name = "rustix" version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ - "bitflags", - "errno 0.3.2", - "io-lifetimes 1.0.11", + "bitflags 1.3.2", + "errno", + "io-lifetimes", "libc", "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", + "windows-sys", +] + +[[package]] +name = "rustix" +version = "0.38.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys 0.4.5", + "windows-sys", ] [[package]] @@ -553,7 +579,7 @@ version = "9.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db7826789c0e25614b03e5a54a0717a86f9ff6e6e5247f92b369472869320039" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "clipboard-win", "dirs-next", @@ -588,9 +614,9 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scroll" @@ -603,9 +629,9 @@ dependencies = [ [[package]] name = "scroll_derive" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdbda6ac5cd1321e724fa9cee216f3a61885889b896f073b8f82322789c5250e" +checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" dependencies = [ "proc-macro2", "quote", @@ -614,15 +640,15 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.137" +version = "1.0.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" dependencies = [ "proc-macro2", "quote", @@ -642,9 +668,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.8.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "smawk" @@ -666,34 +692,15 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.96" +version = "2.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "terminal_size" version = "0.2.6" @@ -701,16 +708,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" dependencies = [ "rustix 0.37.23", - "windows-sys 0.48.0", -] - -[[package]] -name = "textwrap" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" -dependencies = [ - "terminal_size 0.1.17", + "windows-sys", ] [[package]] @@ -720,25 +718,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" dependencies = [ "smawk", - "terminal_size 0.2.6", + "terminal_size", "unicode-linebreak", "unicode-width", ] [[package]] name = "thiserror" -version = "1.0.31" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.31" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" dependencies = [ "proc-macro2", "quote", @@ -747,18 +745,18 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", ] [[package]] name = "unicode-ident" -version = "1.0.0" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-linebreak" @@ -768,9 +766,9 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-segmentation" -version = "1.9.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" @@ -780,36 +778,35 @@ checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "utf8parse" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "which" -version = "4.2.5" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" dependencies = [ "either", - "lazy_static", "libc", + "once_cell", ] [[package]] @@ -843,19 +840,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030b7ff91626e57a05ca64a07c481973cbb2db774e4852c9c7ca342408c6a99a" -dependencies = [ - "windows_aarch64_msvc 0.30.0", - "windows_i686_gnu 0.30.0", - "windows_i686_msvc 0.30.0", - "windows_x86_64_gnu 0.30.0", - "windows_x86_64_msvc 0.30.0", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -872,12 +856,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.48.0", + "windows_x86_64_msvc", ] [[package]] @@ -886,48 +870,24 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_msvc" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29277a4435d642f775f63c7d1faeb927adba532886ce0287bd985bffb16b6bca" - [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_i686_gnu" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145e1989da93956c68d1864f32fb97c8f561a8f89a5125f6a2b7ea75524e4b8" - [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_msvc" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a09e3a0d4753b73019db171c1339cd4362c8c44baf1bcea336235e955954a6" - [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_x86_64_gnu" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ca64fcb0220d58db4c119e050e7af03c69e6f4f415ef69ec1773d9aab422d5a" - [[package]] name = "windows_x86_64_gnu" version = "0.48.0" @@ -940,12 +900,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_msvc" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08cabc9f0066848fef4bc6a1c1668e6efce38b661d2aeec75d18d8617eebb5f1" - [[package]] name = "windows_x86_64_msvc" version = "0.48.0" @@ -954,12 +908,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "xdg" -version = "2.4.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4583db5cbd4c4c0303df2d15af80f0539db703fa1c68802d4cbbd2dd0f88f6" -dependencies = [ - "dirs", -] +checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" [[package]] name = "yabridgectl" @@ -977,7 +928,7 @@ dependencies = [ "serde", "serde_derive", "serde_jsonrc", - "textwrap 0.16.0", + "textwrap", "toml", "walkdir", "which", diff --git a/tools/yabridgectl/Cargo.toml b/tools/yabridgectl/Cargo.toml index 8977c477..bda615f8 100644 --- a/tools/yabridgectl/Cargo.toml +++ b/tools/yabridgectl/Cargo.toml @@ -5,13 +5,13 @@ name = "yabridgectl" version = "5.0.5" authors = ["Robbert van der Helm "] edition = "2021" -description = "Optional utility to help set up yabridge" +description = "Utility for setting up and managing yabridge" repository = "https://github.com/robbert-vdh/yabridge" license = "GPL-3.0-or-later" [dependencies] anyhow = "1.0.52" -clap = { version = "3.0.6", features = ["cargo", "env", "wrap_help"] } +clap = { version = "4.3.21", features = ["cargo", "derive", "wrap_help"] } colored = "2.0.0" is_executable = "1.0.1" goblin = { version = "0.6", default_features = false, features = ["std", "pe32", "pe64"] } diff --git a/tools/yabridgectl/src/actions.rs b/tools/yabridgectl/src/actions.rs index edcf1abd..a0d9b98e 100644 --- a/tools/yabridgectl/src/actions.rs +++ b/tools/yabridgectl/src/actions.rs @@ -17,6 +17,7 @@ //! Handlers for the subcommands, just to keep `main.rs` clean. use anyhow::{Context, Result}; +use clap::ValueEnum; use colored::Colorize; use std::collections::{HashMap, HashSet}; use std::fs; @@ -215,13 +216,23 @@ pub fn show_status(config: &Config) -> Result<()> { } /// Options passed to `yabridgectl set`, see `main()` for the definitions of these options. -pub struct SetOptions<'a> { +pub struct SetOptions { pub path: Option, pub path_auto: bool, - pub vst2_location: Option<&'a str>, + pub vst2_location: Option, pub no_verify: Option, } +/// The location bridged VST2 plugins are set up in. +#[derive(Debug, Clone, Copy, ValueEnum)] +pub enum Vst2Location { + /// Sets bridged VST2 plugins up in '~/.vst/yabridge', the default option. + Centralized, + /// Places the yabridge '.so' file alongside the plugin's '.dll' file in the plugin's directory, + /// exists only for legacy purposes. + Inline, +} + /// Change configuration settings. The actual options are defined in the clap [app](clap::App). pub fn set_settings(config: &mut Config, options: &SetOptions) -> Result<()> { if let Some(path) = &options.path { @@ -233,9 +244,10 @@ pub fn set_settings(config: &mut Config, options: &SetOptions) -> Result<()> { } match options.vst2_location { - Some("centralized") => config.vst2_location = Vst2InstallationLocation::Centralized, - Some("inline") => config.vst2_location = Vst2InstallationLocation::Inline, - Some(s) => unimplemented!("Unexpected installation method '{}'", s), + Some(Vst2Location::Centralized) => { + config.vst2_location = Vst2InstallationLocation::Centralized + } + Some(Vst2Location::Inline) => config.vst2_location = Vst2InstallationLocation::Inline, None => (), } diff --git a/tools/yabridgectl/src/main.rs b/tools/yabridgectl/src/main.rs index 8dcd7dc8..060efcd1 100644 --- a/tools/yabridgectl/src/main.rs +++ b/tools/yabridgectl/src/main.rs @@ -15,12 +15,14 @@ // along with this program. If not, see . use anyhow::Result; -use clap::{command, Arg, Command}; +use clap::builder::TypedValueParser; +use clap::{command, value_parser, Arg, Command}; use colored::Colorize; use std::collections::HashSet; use std::env; use std::path::{Path, PathBuf}; +use crate::actions::Vst2Location; use crate::config::Config; mod actions; @@ -44,15 +46,10 @@ fn main() -> Result<()> { let mut config = Config::read()?; - // Used for validation in `yabridgectl rm ` - let plugin_directories: HashSet<&Path> = config - .plugin_dirs - .iter() - .map(|path| path.as_path()) - .collect(); - // Used for validation in `yabridgectl blacklist rm ` - let blacklist_entries: HashSet<&Path> = - config.blacklist.iter().map(|path| path.as_path()).collect(); + // Used for parsing and validation in `yabridgectl rm ` + let plugin_directories: HashSet = config.plugin_dirs.iter().cloned().collect(); + // Used for parsing and validation in `yabridgectl blacklist rm ` + let blacklist_entries: HashSet = config.blacklist.iter().cloned().collect(); let matches = command!() .subcommand_required(true) @@ -64,8 +61,7 @@ fn main() -> Result<()> { .arg( Arg::new("path") .help("Path to a directory containing Windows VST2, VST3, or CLAP plugins") - .validator(validate_directory) - .takes_value(true) + .value_parser(parse_directory_path) .required(true), ), ) @@ -76,8 +72,7 @@ fn main() -> Result<()> { .arg( Arg::new("path") .help("Path to a previously added directory") - .validator(|path| match_in_path_list(Path::new(path), &plugin_directories)) - .takes_value(true) + .value_parser(parse_path_from_set(plugin_directories)) .required(true), ), ) @@ -138,8 +133,7 @@ fn main() -> Result<()> { then yabridgectl will look in both '/usr/lib' and \ '~/.local/share/yabridge' by default.", ) - .validator(validate_path) - .takes_value(true) + .value_parser(parse_directory_path) .conflicts_with("path_auto"), ) .arg( @@ -156,19 +150,8 @@ fn main() -> Result<()> { Arg::new("vst2_location") .long("vst2-location") .help("Where to set up VST2 plugins") - .long_help( - format!( - "Where to set up VST2 plugins. '{}' (the default) causes bridged \ - VST2 plugins to be set up in `~/.vst/yabridge.` '{}' causes \ - bridged VST2 plugins to be set up next to the original '.dll' \ - file.", - "centralized".bright_white(), - "inline".bright_white() - ) - .as_ref(), - ) - .possible_values(["centralized", "inline"]) - .takes_value(true), + .long_help("Where to set up VST2 plugins.") + .value_parser(value_parser!(Vst2Location)), ) .arg( Arg::new("no_verify") @@ -179,8 +162,7 @@ fn main() -> Result<()> { temporarily by passing the '--no-verify' option to 'yabridgectl \ sync'.", ) - .possible_values(["true", "false"]) - .takes_value(true), + .value_parser(value_parser!(bool)), ), ) .subcommand( @@ -201,8 +183,7 @@ fn main() -> Result<()> { .arg( Arg::new("path") .help("Path to a file or a directory") - .validator(validate_path) - .takes_value(true) + .value_parser(parse_path) .required(true), ), ) @@ -213,11 +194,7 @@ fn main() -> Result<()> { .arg( Arg::new("path") .help("Path to a previously added file or directory") - .validator(|path| { - match_in_path_list(Path::new(path), &blacklist_entries) - }) - .validator(validate_path) - .takes_value(true) + .value_parser(parse_path_from_set(blacklist_entries)) .required(true), ), ) @@ -242,31 +219,24 @@ fn main() -> Result<()> { match matches.subcommand() { Some(("add", options)) => actions::add_directory( &mut config, - options - .value_of_t_or_exit::("path") - .canonicalize()?, + options.get_one::("path").unwrap().canonicalize()?, ), Some(("rm", options)) => { - // Clap sadly doesn't have custom parsers/transforms, so we need to rerun the validator - // to get the result - let path = match_in_path_list( - &options.value_of_t_or_exit::("path"), - &plugin_directories, + actions::remove_directory( + &mut config, + // The parser already ensures that this value exists in the plugin locations set + options.get_one::("path").unwrap(), ) - .unwrap() - .to_owned(); - - actions::remove_directory(&mut config, &path) } Some(("list", _)) => actions::list_directories(&config), Some(("status", _)) => actions::show_status(&config), Some(("sync", options)) => actions::do_sync( &mut config, &actions::SyncOptions { - force: options.is_present("force"), - no_verify: options.is_present("no-verify"), - prune: options.is_present("prune"), - verbose: options.is_present("verbose"), + force: options.get_flag("force"), + no_verify: options.get_flag("no-verify"), + prune: options.get_flag("prune"), + verbose: options.get_flag("verbose"), }, ), Some(("set", options)) => actions::set_settings( @@ -275,30 +245,24 @@ fn main() -> Result<()> { // 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() + .get_one::("path") .and_then(|path| path.canonicalize().ok()), - path_auto: options.is_present("path_auto"), - vst2_location: options.value_of("vst2_location"), - no_verify: options.value_of("no_verify").map(|value| value == "true"), + path_auto: options.get_flag("path_auto"), + vst2_location: options.get_one::("vst2_location").copied(), + no_verify: options.get_one::("no_verify").copied(), }, ), Some(("blacklist", blacklist)) => match blacklist.subcommand() { Some(("add", options)) => actions::blacklist::add_path( &mut config, - options - .value_of_t_or_exit::("path") - .canonicalize()?, + options.get_one::("path").unwrap().canonicalize()?, ), Some(("rm", options)) => { - let path = match_in_path_list( - &options.value_of_t_or_exit::("path"), - &blacklist_entries, + actions::blacklist::remove_path( + &mut config, + // The parser already ensures that this value exists in the plugin locations set + options.get_one::("path").unwrap(), ) - .unwrap() - .to_owned(); - - actions::blacklist::remove_path(&mut config, &path) } Some(("list", _)) => actions::blacklist::list_paths(&config), Some(("clear", _)) => actions::blacklist::clear(&mut config), @@ -308,76 +272,86 @@ fn main() -> Result<()> { } } -/// Verify that a path exists and that is is either a directory or a symlink to a directory. -fn validate_directory(path: &str) -> Result<(), String> { - validate_path(path)?; - - let path = Path::new(path); - if path.is_dir() { - Ok(()) - } else { - Err(format!("'{}' is not a directory", path.display())) - } -} - -/// Verify that a path exists, used for validating arguments. -fn validate_path(path: &str) -> Result<(), String> { +/// Verify that a path exists. Used for validating arguments. +fn parse_path(path: &str) -> Result { let path = Path::new(path); if path.exists() { - Ok(()) + Ok(path.to_owned()) } else { + Err(String::from("File or directory could not be found.")) + } +} + +/// [`parse_path()`], but for directories or symlinks to directories. +fn parse_directory_path(path: &str) -> Result { + let path = Path::new(path); + + if path.exists() { + if path.is_dir() { + Ok(path.to_owned()) + } else { + Err(String::from("Path is not a directory.")) + } + } else { + Err(String::from("Directory could not be found.")) + } +} + +/// Constructs a parser that checks if `path` is in the set of locations, and returns an absolute +/// path to the location if it is. This is similar to using `Arg::possible_values()`, except that it +/// also tries to resolve symlinks, relative paths, and other common variations. If the path is +/// relative, we will try to resolve as much of it as possible (in case the referred to file doesn't +/// exist anymore). We don't iteratively try to resolve symlinks until a candidate matches a path in +/// `candidates`, but this can match a relative path to a symlink that's in the paths list. +fn parse_path_from_set(candidates: HashSet) -> impl TypedValueParser { + move |value: &str| -> Result { + // This path does not need to exist, since a plugin location may no longer exist on disk + let path = Path::new(value); + let absolute_path = if path.is_absolute() { + path.to_path_buf() + } else { + // This absolute absolute_path is also needed for the `utils::normalize_path()` below + std::env::current_dir() + .expect("Couldn't get current directory") + .join(path) + }; + + // If the absolute path is not in the plugin locations verbatim, we'll try a couple + // different variations + if let Some(matching_path) = candidates.get(absolute_path.as_path()) { + return Ok(matching_path.to_path_buf()); + } + + // This will include a trailing slash if `path` was `.`. All paths entered through + // yabridgectl will be cannonicalized and won't contain a trailing slash, but we'll try both + // variants anyways just in case someone edited the config file. + let normalized_path = util::normalize_path(absolute_path.as_path()); + + // Is there a nicer way to strip trailing slashes with the standard library? + let normalized_path_str = normalized_path + .to_str() + .expect("Input path contains invalid characters"); + let normalized_path_without_slash = if normalized_path_str.ends_with('/') { + Path::new(normalized_path_str.trim_end_matches('/')) + } else { + normalized_path.as_path() + }; + // This ia bit of a hack, but it works + let normalized_path_with_slash = normalized_path.join(""); + + if let Some(found_path) = candidates + .get(normalized_path_without_slash) + .or_else(|| candidates.get(normalized_path_with_slash.as_path())) + { + return Ok(found_path.to_path_buf()); + } + + // There's sadly no way to use clap's normal error formatting for possible values here since + // parts of the API are not exposed Err(format!( - "File or directory '{}' could not be found", - path.display() + "Not a known path.\n\n Possible options are: {}", + format!("{:?}", candidates).green() )) } } - -/// Find `path` in `candidates` and return it as an absolute path. If the path is relative, we will -/// try to resolve as much of it as possible (in case the referred to file doesn't exist anymore). -/// We don't iteratively try to resolve symlinks until a candidate matches a path in `candidates`, -/// but this can match a relative path to a symlink that's in the paths list. -fn match_in_path_list<'a>(path: &Path, candidates: &'a HashSet<&Path>) -> Result<&'a Path, String> { - let absolute_path = if path.is_absolute() { - path.to_owned() - } else { - // This absolute absolute_path is also needed for the `utils::normalize_path()` below - std::env::current_dir() - .expect("Couldn't get current directory") - .join(path) - }; - if let Some(path) = candidates.get(absolute_path.as_path()) { - return Ok(path); - } - - // This will include a trailing slash if `path` was `.`. All paths entered through yabridgectl - // will be cannonicalized and won't contain a trailing slash, but we'll try both variants - // anyways just in case someone edited the config file. - let normalized_path = util::normalize_path(absolute_path.as_path()); - - // Is there a nicer way to strip trailing slashes with the standard library? - let normalized_path_str = normalized_path - .to_str() - .expect("Input path contains invalid characters"); - let normalized_path_without_slash = if normalized_path_str.ends_with('/') { - Path::new(normalized_path_str.trim_end_matches('/')) - } else { - normalized_path.as_path() - }; - // This ia bit of a hack, but it works - let normalized_path_with_slash = normalized_path.join(""); - - if let Some(path) = candidates - .get(normalized_path_without_slash) - .or_else(|| candidates.get(normalized_path_with_slash.as_path())) - { - return Ok(path); - } - - Err(format!( - "'{}' is not a known path.\n\n\tPossible options are: {}", - path.display(), - format!("{:?}", candidates).green() - )) -}