lib: Various realm / flux fixes

This commit is contained in:
Erik Kundt
2024-02-23 16:23:03 +01:00
parent 06a01946c2
commit 98b54a4ffe
7 changed files with 13 additions and 71 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ name = "rad-tui"
path = "bin/main.rs"
[features]
default = ["realm"]
default = ["flux"]
realm = ["dep:tuirealm", "dep:tui-realm-stdlib"]
flux = ["dep:tokio", "dep:tokio-stream"]
+4 -2
View File
@@ -127,10 +127,9 @@ impl Args for Options {
#[cfg(feature = "realm")]
pub fn run(options: Options, _ctx: impl terminal::Context) -> anyhow::Result<()> {
use tui::common::context;
use tui::realm::Window;
use tui::common::context;
use tui::common::log;
use tui::realm::Window;
pub const FPS: u64 = 60;
let (_, id) = radicle::rad::cwd()
@@ -162,6 +161,7 @@ pub fn run(options: Options, _ctx: impl terminal::Context) -> anyhow::Result<()>
#[tokio::main]
pub async fn run(options: Options, _ctx: impl terminal::Context) -> anyhow::Result<()> {
use radicle::storage::ReadStorage;
use tui::common::log;
let (_, rid) = radicle::rad::cwd()
.map_err(|_| anyhow!("this command must be run in the context of a project"))?;
@@ -189,4 +189,6 @@ pub async fn run(options: Options, _ctx: impl terminal::Context) -> anyhow::Resu
eprint!("{output}");
}
}
Ok(())
}
+2
View File
@@ -0,0 +1,2 @@
#[path = "flux/select.rs"]
pub mod select;
-31
View File
@@ -5,12 +5,10 @@ mod page;
#[path = "select/ui.rs"]
mod ui;
use std::fmt::Display;
use std::hash::Hash;
use anyhow::Result;
use radicle::issue::IssueId;
use serde::Serialize;
use tuirealm::application::PollStrategy;
use tuirealm::event::Key;
@@ -32,35 +30,6 @@ use super::super::common::Mode;
type Selection = tui::Selection<IssueId>;
/// The selected issue operation returned by the operation
/// selection widget.
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub enum IssueOperation {
Show,
Delete,
Edit,
Comment,
}
impl Display for IssueOperation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
IssueOperation::Show => {
write!(f, "show")
}
IssueOperation::Delete => {
write!(f, "delete")
}
IssueOperation::Edit => {
write!(f, "edit")
}
IssueOperation::Comment => {
write!(f, "comment")
}
}
}
}
#[derive(Debug, Eq, PartialEq, Clone, Hash)]
pub enum ListCid {
Header,
+3 -1
View File
@@ -12,8 +12,10 @@ use tui::realm::ui::widget::context::{ContextBar, Shortcuts};
use tui::realm::ui::widget::list::PropertyList;
use tui::realm::ui::widget::Widget;
use crate::tui_issue::common::IssueOperation;
use super::ui::{IdSelect, OperationSelect};
use super::{IssueOperation, Message};
use super::Message;
type Selection = tui::Selection<IssueId>;
-35
View File
@@ -5,12 +5,10 @@ mod page;
#[path = "select/ui.rs"]
mod ui;
use std::fmt::Display;
use std::hash::Hash;
use anyhow::Result;
use radicle::patch::PatchId;
use serde::Serialize;
use tuirealm::application::PollStrategy;
use tuirealm::event::Key;
@@ -32,39 +30,6 @@ use super::super::common::Mode;
type Selection = tui::Selection<PatchId>;
/// The selected patch operation returned by the operation
/// selection widget.
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub enum PatchOperation {
Show,
Checkout,
Delete,
Edit,
Comment,
}
impl Display for PatchOperation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
PatchOperation::Show => {
write!(f, "show")
}
PatchOperation::Checkout => {
write!(f, "checkout")
}
PatchOperation::Delete => {
write!(f, "delete")
}
PatchOperation::Edit => {
write!(f, "edit")
}
PatchOperation::Comment => {
write!(f, "comment")
}
}
}
}
#[derive(Debug, Eq, PartialEq, Clone, Hash)]
pub enum ListCid {
Header,
+3 -1
View File
@@ -11,8 +11,10 @@ use tui::realm::ui::widget::context::{ContextBar, Shortcuts};
use tui::realm::ui::widget::list::PropertyList;
use tui::realm::ui::widget::Widget;
use crate::tui_patch::common::PatchOperation;
use super::ui::{IdSelect, OperationSelect};
use super::{Message, PatchOperation};
use super::Message;
type Selection = tui::Selection<PatchId>;