Change minor things

This commit is contained in:
Ottatop 2024-03-04 14:44:33 -06:00
parent 2a70ba4d69
commit f9ca886ed9
3 changed files with 27 additions and 13 deletions

22
Cargo.lock generated
View file

@ -310,6 +310,17 @@ dependencies = [
"objc2",
]
[[package]]
name = "bstr"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc"
dependencies = [
"memchr",
"regex-automata 0.4.5",
"serde",
]
[[package]]
name = "bumpalo"
version = "3.14.0"
@ -1658,6 +1669,15 @@ dependencies = [
"libredox 0.0.2",
]
[[package]]
name = "os_str_bytes"
version = "6.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
dependencies = [
"memchr",
]
[[package]]
name = "overload"
version = "0.1.1"
@ -2187,7 +2207,9 @@ version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b"
dependencies = [
"bstr",
"dirs",
"os_str_bytes",
]
[[package]]

View file

@ -62,7 +62,7 @@ cliclack = "0.1.13"
bitflags = "2.4.2"
serde = { version = "1.0.196", features = ["derive"] }
toml = "0.8.10"
shellexpand = "3.1.0"
shellexpand = { version = "3.1.0", features = ["path"] }
x11rb = { version = "0.13.0", default-features = false, features = ["composite"] }
xkbcommon = { workspace = true }
xdg = { workspace = true }

View file

@ -56,15 +56,9 @@ impl Cli {
// oh my god rustfmt is starting to piss me off
cli.config_dir = cli.config_dir.and_then(|dir| {
let Some(dir) = dir.to_str() else {
warn!(
"Could not convert `--config-dir`'s argument to `&str`; unsetting `--config-dir`"
);
return None;
};
let new_dir = shellexpand::full(dir);
let new_dir = shellexpand::path::full(&dir);
match new_dir {
Ok(new_dir) => Some(PathBuf::from(new_dir.to_string())),
Ok(new_dir) => Some(new_dir.to_path_buf()),
Err(err) => {
warn!("Could not shellexpand `--config-dir`'s argument: {err}; unsetting `--config-dir`");
None
@ -147,7 +141,6 @@ impl std::fmt::Display for Lang {
//////////////////////////////////////////////////////////////////////
// Pretty sure this function returns Result purely for testing which I don't *really* like
/// Generate a new config.
///
/// If `--non-interactive` is passed or the shell is non-interactive, this will not
@ -289,13 +282,12 @@ fn generate_config(args: ConfigGen) -> anyhow::Result<()> {
None => {
assert!(interactive);
let dir: String = cliclack::input("Choose a directory to place the config in:")
let dir: PathBuf = cliclack::input("Choose a directory to place the config in:")
.default_input(default_dir.to_string_lossy().as_ref())
.validate_interactively(dir_validator)
.interact()?;
let dir = shellexpand::full(&dir)?;
let mut dir = PathBuf::from(dir.to_string());
let mut dir = shellexpand::path::full(&dir)?.to_path_buf();
if dir.is_relative() {
let mut new_dir = std::env::current_dir()?;