From 4a8761fba64d9a34b78ad2edcf43a3d8ce5e3103 Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Tue, 11 Jun 2024 00:00:00 +0000 Subject: [PATCH] =?UTF-8?q?pcli:=20=F0=9F=8C=B7=20add=20a=20top-level=20`-?= =?UTF-8?q?-grpc-url`=20override?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 3f7ccbd7bd91bc67c05a4d46d515ca5abdf3f241) --- crates/bin/pcli/src/opt.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/bin/pcli/src/opt.rs b/crates/bin/pcli/src/opt.rs index c1ed746db0..c2d3e608b5 100644 --- a/crates/bin/pcli/src/opt.rs +++ b/crates/bin/pcli/src/opt.rs @@ -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)] @@ -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, } impl Opt { @@ -49,7 +55,11 @@ impl Opt { pub fn load_config(&self) -> Result { 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)> {