Skip to content

Commit

Permalink
Swtich from xdg to directories crate for Windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer committed Aug 18, 2023
1 parent 1a93511 commit d13b153
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
37 changes: 29 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ bcrypt = "0.15"
clap = { version = "4.2.1", features = ["derive", "env"] }
clap_complete = "4.2"
comfy-table = { version = "7.0", features = ["custom_styling"] }
directories = "5.0"
dotenvy = "0.15"
futures = "0.3"
gobuild = "0.1.0-alpha.2"
Expand Down Expand Up @@ -45,7 +46,6 @@ utoipa = { version = "3.3", features = ["indexmap"] }
utoipa-swagger-ui = { version = "3.1", features = ["axum"] }
uuid = { version = "1.4.0", features = ["v4"] }
which = "4.4"
xdg = "2.4"

[patch."https://github.com/stackabletech/operator-rs.git"]
# TODO: Switch to released version
Expand Down
2 changes: 1 addition & 1 deletion rust/stackablectl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ stackable-cockpit = { path = "../stackable-cockpit", features = ["openapi"] }
clap_complete.workspace = true
clap.workspace = true
comfy-table.workspace = true
directories.workspace = true
dotenvy.workspace = true
indexmap.workspace = true
lazy_static.workspace = true
Expand All @@ -27,4 +28,3 @@ snafu.workspace = true
tokio.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true
xdg.workspace = true
13 changes: 7 additions & 6 deletions rust/stackablectl/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::env;

use clap::{Parser, Subcommand, ValueEnum};
use snafu::{ResultExt, Snafu};
use directories::BaseDirs;
use snafu::{OptionExt, Snafu};
use tracing::{debug, instrument, Level};

use stackable_cockpit::{
Expand Down Expand Up @@ -123,9 +124,9 @@ impl Cli {
if self.no_cache {
Ok(CacheSettings::disabled())
} else {
let xdg = xdg::BaseDirectories::with_prefix(CACHE_HOME_PATH)
.context(cache_settings_error::XdgSnafu)?;
Ok(CacheSettings::disk(xdg.get_cache_home()))
let dirs = BaseDirs::new().context(cache_settings_error::BaseDirsSnafu)?;
let cache_dir = dirs.cache_dir().join(CACHE_HOME_PATH);
Ok(CacheSettings::disk(cache_dir))
}
}
}
Expand Down Expand Up @@ -184,8 +185,8 @@ pub enum OutputType {
#[derive(Debug, Snafu)]
#[snafu(module)]
pub enum CacheSettingsError {
#[snafu(display("unable to resolve XDG directories"))]
Xdg { source: xdg::BaseDirectoriesError },
#[snafu(display("unable to resolve base directories"))]
BaseDirs {},
}

pub struct InheritStackDemoArgs {}
Expand Down

0 comments on commit d13b153

Please sign in to comment.