diff --git a/bin/commands/issue/suite.rs b/bin/commands/issue/suite.rs index da0aee14..f7c51ac1 100644 --- a/bin/commands/issue/suite.rs +++ b/bin/commands/issue/suite.rs @@ -285,7 +285,7 @@ impl App { assignees: String, ) -> Result { let repository = self.context.repository(); - let signer = self.context.signer(); + let signer = self.context.signer().as_ref().unwrap(); let labels = cob::parse_labels(labels)?; let assignees = cob::parse_assignees(assignees)?; diff --git a/bin/commands/patch.rs b/bin/commands/patch.rs index 4d71e271..32d47f8b 100644 --- a/bin/commands/patch.rs +++ b/bin/commands/patch.rs @@ -73,11 +73,11 @@ pub fn run(options: Options, _ctx: impl terminal::Context) -> anyhow::Result<()> let (_, id) = radicle::rad::cwd() .map_err(|_| anyhow!("this command must be run in the context of a project"))?; - let context = context::Context::new(id)?.with_patches(); - match options.op { Operation::List => { - log::enable("patch", "list", context.profile())?; + let context = context::Context::new(id)?.with_patches(); + + log::enable(context.profile(), "patch", "list")?; let patch_id = Window::default() .run(&mut list::App::new(context), 1000 / FPS)? diff --git a/src/context.rs b/src/context.rs index 9dbff4ed..55e026d4 100644 --- a/src/context.rs +++ b/src/context.rs @@ -40,17 +40,17 @@ pub struct Context { repository: Repository, issues: Option>, patches: Option>, - signer: Box, + signer: Option>, } impl Context { pub fn new(id: Id) -> Result { let profile = profile()?; - let signer = signer(&profile)?; let repository = profile.storage.repository(id).unwrap(); let project = repository.identity_doc()?.project()?; let issues = None; let patches = None; + let signer = None; Ok(Self { id, @@ -75,6 +75,11 @@ impl Context { self } + pub fn with_signer(mut self) -> Self { + self.signer = signer(&self.profile).ok(); + self + } + pub fn profile(&self) -> &Profile { &self.profile } @@ -100,7 +105,7 @@ impl Context { } #[allow(clippy::borrowed_box)] - pub fn signer(&self) -> &Box { + pub fn signer(&self) -> &Option> { &self.signer } diff --git a/src/log.rs b/src/log.rs index 8d8dc2f7..fe39ad15 100644 --- a/src/log.rs +++ b/src/log.rs @@ -2,7 +2,7 @@ use log::LevelFilter; use radicle::profile::Profile; -pub fn enable(cmd: &str, op: &str, profile: &Profile) -> Result<(), anyhow::Error> { +pub fn enable(profile: &Profile, cmd: &str, op: &str) -> Result<(), anyhow::Error> { let logfile = format!( "{}/rad-tui-{}-{}.log", profile.home().path().to_string_lossy(),