Skip to content

Commit

Permalink
feat: change default dir back to shared home location (#471)
Browse files Browse the repository at this point in the history
fall back to current directory. updated cli to show default value in help
  • Loading branch information
dav1do authored Aug 7, 2024
1 parent e9675ab commit 6ce0aba
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 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 @@ -61,7 +61,7 @@ ceramic-service = { path = "./service" }
ceramic-store = { path = "./store" }
chrono = "0.4.31"
cid = { version = "0.11", features = ["serde-codec"] }
clap = { version = "4", features = ["derive", "env"] }
clap = { version = "4", features = ["derive", "env", "string"] }
clap_mangen = "0.2.2"
console = { version = "0.15", default-features = false }
console-subscriber = "0.2"
Expand Down
1 change: 1 addition & 0 deletions one/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cid.workspace = true
clap.workspace = true
futures.workspace = true
git-version = "0.3"
home = "0.5"
hyper.workspace = true
iroh-bitswap.workspace = true
iroh-rpc-client.workspace = true
Expand Down
15 changes: 12 additions & 3 deletions one/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct DaemonOpts {
db_opts: DBOpts,

/// Path to libp2p private key directory
#[arg(short, long, default_value = ".", env = "CERAMIC_ONE_P2P_KEY_DIR")]
#[arg(short, long, default_value=default_directory().into_os_string(), env = "CERAMIC_ONE_P2P_KEY_DIR")]
p2p_key_dir: PathBuf,

/// Bind address of the API endpoint.
Expand Down Expand Up @@ -189,10 +189,19 @@ struct DaemonOpts {
feature_flags: Vec<FeatureFlags>,
}

/// The default storage directory to use if none is provided. In order:
/// - `$HOME/.ceramic-one`
/// - `./.ceramic-one`
fn default_directory() -> PathBuf {
home::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
.join(".ceramic-one")
}

#[derive(Args, Debug)]
struct DBOpts {
/// Path to storage directory
#[arg(short, long, default_value = ".", env = "CERAMIC_ONE_STORE_DIR")]
/// Path to storage directory.
#[arg(short, long, default_value=default_directory().into_os_string(), env = "CERAMIC_ONE_STORE_DIR")]
store_dir: PathBuf,
}

Expand Down
4 changes: 2 additions & 2 deletions one/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use futures::{stream::BoxStream, StreamExt};
use multihash_codetable::{Code, Multihash, MultihashDigest};
use tracing::{debug, info};

use crate::{DBOpts, Info, LogOpts};
use crate::{default_directory, DBOpts, Info, LogOpts};

#[derive(Subcommand, Debug)]
pub enum EventsCommand {
Expand All @@ -38,7 +38,7 @@ pub struct FromIpfsOpts {
#[clap(
long,
short,
default_value = ".",
default_value=default_directory().into_os_string(),
env = "CERAMIC_ONE_OUTPUT_STORE_PATH"
)]
output_store_path: PathBuf,
Expand Down

0 comments on commit 6ce0aba

Please sign in to comment.