Skip to content

Commit

Permalink
Make pclientd/pcli default_home accessible when using them as librari…
Browse files Browse the repository at this point in the history
…es (#4729)

## Describe your changes

Changes the location and exposure of the `default_home` functions in
`pcli`/`pclientd` so they can be accessed when used as libraries.

## Checklist before requesting a review

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

  > minor change to client code organization
  • Loading branch information
zbuc authored Jul 22, 2024
1 parent 5bc9346 commit 61e4419
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 10 additions & 0 deletions crates/bin/pcli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use {
crate::{command::*, config::PcliConfig},
anyhow::Result,
camino::Utf8PathBuf,
directories::ProjectDirs,
futures::StreamExt,
penumbra_proto::{
box_grpc_svc::BoxGrpcService, custody::v1::custody_service_client::CustodyServiceClient,
Expand Down Expand Up @@ -81,3 +83,11 @@ impl App {
Ok(())
}
}

pub fn default_home() -> Utf8PathBuf {
let path = ProjectDirs::from("zone", "penumbra", "pcli")
.expect("Failed to get platform data dir")
.data_dir()
.to_path_buf();
Utf8PathBuf::from_path_buf(path).expect("Platform default data dir was not UTF-8")
}
10 changes: 1 addition & 9 deletions crates/bin/pcli/src/opt.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::{
config::{CustodyConfig, GovernanceCustodyConfig, PcliConfig},
default_home,
terminal::ActualTerminal,
App, Command,
};
use anyhow::Result;
use camino::Utf8PathBuf;
use clap::Parser;
use directories::ProjectDirs;
use penumbra_custody::{null_kms::NullKms, soft_kms::SoftKms};
use penumbra_proto::box_grpc_svc;
use penumbra_proto::{
Expand Down Expand Up @@ -178,11 +178,3 @@ impl Opt {
Ok((app, self.cmd))
}
}

fn default_home() -> Utf8PathBuf {
let path = ProjectDirs::from("zone", "penumbra", "pcli")
.expect("Failed to get platform data dir")
.data_dir()
.to_path_buf();
Utf8PathBuf::from_path_buf(path).expect("Platform default data dir was not UTF-8")
}
2 changes: 1 addition & 1 deletion crates/bin/pclientd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl PclientdConfig {
}
}

fn default_home() -> Utf8PathBuf {
pub fn default_home() -> Utf8PathBuf {
let path = ProjectDirs::from("zone", "penumbra", "pclientd")
.expect("Failed to get platform data dir")
.data_dir()
Expand Down

0 comments on commit 61e4419

Please sign in to comment.