From 98b54a4ffef4f6f78dcbe9d06649e9601a42e724 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Fri, 23 Feb 2024 16:23:03 +0100 Subject: [PATCH] lib: Various realm / flux fixes --- Cargo.toml | 2 +- bin/commands/inbox.rs | 6 ++-- bin/commands/inbox/flux.rs | 2 ++ bin/commands/issue/realm/select.rs | 31 --------------------- bin/commands/issue/realm/select/event.rs | 4 ++- bin/commands/patch/realm/select.rs | 35 ------------------------ bin/commands/patch/realm/select/event.rs | 4 ++- 7 files changed, 13 insertions(+), 71 deletions(-) create mode 100644 bin/commands/inbox/flux.rs diff --git a/Cargo.toml b/Cargo.toml index 72053afa..071372c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] diff --git a/bin/commands/inbox.rs b/bin/commands/inbox.rs index f33b9bf4..417811cf 100644 --- a/bin/commands/inbox.rs +++ b/bin/commands/inbox.rs @@ -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(()) } diff --git a/bin/commands/inbox/flux.rs b/bin/commands/inbox/flux.rs new file mode 100644 index 00000000..ffc8d2d0 --- /dev/null +++ b/bin/commands/inbox/flux.rs @@ -0,0 +1,2 @@ +#[path = "flux/select.rs"] +pub mod select; diff --git a/bin/commands/issue/realm/select.rs b/bin/commands/issue/realm/select.rs index 7244825f..a3e5daf2 100644 --- a/bin/commands/issue/realm/select.rs +++ b/bin/commands/issue/realm/select.rs @@ -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; -/// 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, diff --git a/bin/commands/issue/realm/select/event.rs b/bin/commands/issue/realm/select/event.rs index 8dab4063..ed2e0e74 100644 --- a/bin/commands/issue/realm/select/event.rs +++ b/bin/commands/issue/realm/select/event.rs @@ -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; diff --git a/bin/commands/patch/realm/select.rs b/bin/commands/patch/realm/select.rs index 27e9c8eb..38be400c 100644 --- a/bin/commands/patch/realm/select.rs +++ b/bin/commands/patch/realm/select.rs @@ -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; -/// 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, diff --git a/bin/commands/patch/realm/select/event.rs b/bin/commands/patch/realm/select/event.rs index 2939d860..d0c44ef7 100644 --- a/bin/commands/patch/realm/select/event.rs +++ b/bin/commands/patch/realm/select/event.rs @@ -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;