Skip to content

Commit

Permalink
pcli: 🌷 add a top-level --grpc-url override
Browse files Browse the repository at this point in the history
when a pcli user initializes their configuration, they provide the
`init` command with the grpc url of a fullnode, which is stored in
pcli's configuration file. by default, this is found at
`~/.local/share/pcli/config.toml`.

if that fullnode is later encountering issues, this can render many pcli
commands unusable, without a clear workaround. this is a small patch,
providing a top-level `--grpc-url` option that will override the config
file's GRPC url.

this can help users temporarily send requests to a different fullnode,
until their preferred default comes back online.

(cherry picked from commit 3f7ccbd)
  • Loading branch information
cratelyn authored and conorsch committed Jun 20, 2024
1 parent 7726b0c commit 4a8761f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/bin/pcli/src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use penumbra_proto::{
use penumbra_view::ViewServer;
use std::io::IsTerminal as _;
use tracing_subscriber::EnvFilter;
use url::Url;

#[derive(Debug, Parser)]
#[clap(name = "pcli", about = "The Penumbra command-line interface.", version)]
Expand All @@ -27,6 +28,11 @@ pub struct Opt {
/// The home directory used to store configuration and data.
#[clap(long, default_value_t = default_home(), env = "PENUMBRA_PCLI_HOME")]
pub home: Utf8PathBuf,
/// Override the GRPC URL that will be used to connect to a fullnode.
///
/// By default, this URL is provided by pcli's config. See `pcli init` for more information.
#[clap(long, parse(try_from_str = Url::parse))]
pub grpc_url: Option<Url>,
}

impl Opt {
Expand All @@ -49,7 +55,11 @@ impl Opt {

pub fn load_config(&self) -> Result<PcliConfig> {
let path = self.home.join(crate::CONFIG_FILE_NAME);
PcliConfig::load(path)
let mut config = PcliConfig::load(path)?;
if let Some(grpc_url) = &self.grpc_url {
config.grpc_url = grpc_url.clone();
}
Ok(config)
}

pub async fn into_app(self) -> Result<(App, Command)> {
Expand Down

0 comments on commit 4a8761f

Please sign in to comment.