mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-29 06:20:28 +08:00
lib: Make signer context optional
This commit is contained in:
+8
-3
@@ -40,17 +40,17 @@ pub struct Context {
|
||||
repository: Repository,
|
||||
issues: Option<Vec<(IssueId, Issue)>>,
|
||||
patches: Option<Vec<(PatchId, Patch)>>,
|
||||
signer: Box<dyn Signer>,
|
||||
signer: Option<Box<dyn Signer>>,
|
||||
}
|
||||
|
||||
impl Context {
|
||||
pub fn new(id: Id) -> Result<Self, anyhow::Error> {
|
||||
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<dyn Signer> {
|
||||
pub fn signer(&self) -> &Option<Box<dyn Signer>> {
|
||||
&self.signer
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user