mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-16 08:20:39 +08:00
patch-list: Add implementation
This commit is contained in:
+23
-7
@@ -1,3 +1,5 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use radicle_term as term;
|
||||
|
||||
use radicle::cob::issue::{Issue, IssueId};
|
||||
@@ -6,16 +8,31 @@ use radicle::crypto::ssh::keystore::{Keystore, MemorySigner};
|
||||
use radicle::crypto::Signer;
|
||||
use radicle::prelude::{Id, Project};
|
||||
use radicle::profile::env::RAD_PASSPHRASE;
|
||||
use radicle::storage::ReadRepository;
|
||||
use radicle::Profile;
|
||||
|
||||
use radicle::storage::git::Repository;
|
||||
use radicle::storage::ReadStorage;
|
||||
use radicle::storage::{ReadRepository, ReadStorage};
|
||||
|
||||
use radicle::Profile;
|
||||
|
||||
use term::{passphrase, spinner, Passphrase};
|
||||
|
||||
use inquire::validator;
|
||||
|
||||
/// Git revision parameter. Supports extended SHA-1 syntax.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Rev(String);
|
||||
|
||||
impl From<String> for Rev {
|
||||
fn from(value: String) -> Self {
|
||||
Rev(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Rev {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Context {
|
||||
profile: Profile,
|
||||
id: Id,
|
||||
@@ -32,12 +49,11 @@ impl Context {
|
||||
let signer = signer(&profile)?;
|
||||
|
||||
let repository = profile.storage.repository(id).unwrap();
|
||||
let doc = repository.identity_doc()?;
|
||||
let project = doc.project()?;
|
||||
|
||||
let issues = crate::cob::issue::all(&repository).unwrap_or_default();
|
||||
let patches = crate::cob::patch::all(&repository).unwrap_or_default();
|
||||
|
||||
let project = repository.identity_doc()?.project()?;
|
||||
|
||||
Ok(Self {
|
||||
id,
|
||||
profile,
|
||||
|
||||
+13
-8
@@ -37,8 +37,13 @@ where
|
||||
/// Should draw the application to a frame.
|
||||
fn view(&mut self, app: &mut Application<Id, Message, NoUserEvent>, frame: &mut Frame);
|
||||
|
||||
/// Should return true if the application is requested to quit.
|
||||
fn quit(&self) -> bool;
|
||||
/// Should return `Some` if the application is requested to quit.
|
||||
fn exit(&self) -> Option<Exit>;
|
||||
}
|
||||
|
||||
/// An optional return value.
|
||||
pub struct Exit {
|
||||
pub value: Option<String>,
|
||||
}
|
||||
|
||||
/// A tui-window using the cross-platform Terminal helper provided
|
||||
@@ -59,9 +64,9 @@ impl Window {
|
||||
/// Creates a tui-window using the default cross-platform Terminal
|
||||
/// helper and panics if its creation fails.
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
terminal: TerminalBridge::new().expect("Cannot create terminal bridge"),
|
||||
}
|
||||
let terminal = TerminalBridge::new().expect("Cannot create terminal bridge");
|
||||
|
||||
Self { terminal }
|
||||
}
|
||||
|
||||
/// Runs this tui-window with the tui-application given and performs the
|
||||
@@ -72,7 +77,7 @@ impl Window {
|
||||
/// - update application state
|
||||
/// - redraw view
|
||||
/// 3. Leave alternative terminal screen
|
||||
pub fn run<T, Id, Message>(&mut self, tui: &mut T, interval: u64) -> Result<()>
|
||||
pub fn run<T, Id, Message>(&mut self, tui: &mut T, interval: u64) -> Result<Option<String>>
|
||||
where
|
||||
T: Tui<Id, Message>,
|
||||
Id: Eq + PartialEq + Clone + Hash,
|
||||
@@ -86,7 +91,7 @@ impl Window {
|
||||
);
|
||||
tui.init(&mut app)?;
|
||||
|
||||
while !tui.quit() {
|
||||
while tui.exit().is_none() {
|
||||
if update || resize {
|
||||
self.terminal
|
||||
.raw_mut()
|
||||
@@ -98,7 +103,7 @@ impl Window {
|
||||
size = self.terminal.raw().size()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(tui.exit().unwrap().value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user