diff --git a/radicle-cli/examples/rad-inbox.md b/radicle-cli/examples/rad-inbox.md new file mode 100644 index 000000000..d48620ff1 --- /dev/null +++ b/radicle-cli/examples/rad-inbox.md @@ -0,0 +1,108 @@ +``` ~alice +$ cd heartwood +$ rad inbox +Your inbox is empty. +``` + +``` ~bob +$ cd heartwood +$ rad issue open --title "No license file" --description "..." -q +✓ Synced with 1 node(s) +$ git commit -m "Change copyright" --allow-empty -q +$ git push rad HEAD:bob/copy +$ cd .. +$ cd radicle-git +$ git commit -m "Change copyright" --allow-empty -q +$ git push rad -o patch.message="Copyright fixes" HEAD:refs/patches +``` + +``` ~alice +$ rad inbox --sort-by id +╭──────────────────────────────────────────────────────────────╮ +│ heartwood │ +├──────────────────────────────────────────────────────────────┤ +│ 1 ● issue No license file [ .. ] opened now │ +│ 2 ● branch Change copyright bob/copy created now │ +╰──────────────────────────────────────────────────────────────╯ +``` + +``` ~alice +$ rad inbox --all --sort-by id +╭──────────────────────────────────────────────────────────────╮ +│ heartwood │ +├──────────────────────────────────────────────────────────────┤ +│ 1 ● issue No license file [ .. ] opened now │ +│ 2 ● branch Change copyright bob/copy created now │ +╰──────────────────────────────────────────────────────────────╯ +╭──────────────────────────────────────────────────────────╮ +│ radicle-git │ +├──────────────────────────────────────────────────────────┤ +│ 3 ● patch Copyright fixes [ ... ] opened now │ +╰──────────────────────────────────────────────────────────╯ +``` + +``` ~alice +$ rad inbox show 2 +commit 141c9073066e3910f1dfe356904a0120542e1cc9 +Author: radicle +Date: Thu Dec 15 17:28:04 2022 +0000 + + Change copyright + +commit f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354 +Author: anonymous +Date: Mon Jan 1 14:39:16 2018 +0000 + + Second commit + +commit 08c788dd1be6315de09e3fe09b5b1b7a2b8711d9 +Author: anonymous +Date: Mon Jan 1 14:39:16 2018 +0000 + + Initial commit +``` + +``` ~alice +$ rad inbox list --sort-by id +╭──────────────────────────────────────────────────────────────╮ +│ heartwood │ +├──────────────────────────────────────────────────────────────┤ +│ 1 ● issue No license file [ ... ] opened now │ +│ 2 branch Change copyright bob/copy created now │ +╰──────────────────────────────────────────────────────────────╯ +``` + +``` ~alice +$ rad inbox show 1 +╭──────────────────────────────────────────────────╮ +│ Title No license file │ +│ Issue [ ... ] │ +│ Author bob z6Mkt67…v4N1tRk │ +│ Status open │ +│ │ +│ ... │ +╰──────────────────────────────────────────────────╯ +``` + +``` ~alice +$ rad inbox clear +✓ Cleared 2 item(s) from your inbox +$ rad inbox +Your inbox is empty. +$ rad inbox --all +╭──────────────────────────────────────────────────────────╮ +│ radicle-git │ +├──────────────────────────────────────────────────────────┤ +│ 3 ● patch Copyright fixes [ ... ] opened now │ +╰──────────────────────────────────────────────────────────╯ +``` + +``` ~alice +$ rad inbox clear --all +✓ Cleared 1 item(s) from your inbox +``` + +``` ~alice +$ rad inbox clear --all +Your inbox is empty. +``` diff --git a/radicle-cli/examples/workflow/5-patching-maintainer.md b/radicle-cli/examples/workflow/5-patching-maintainer.md index b28671a29..45b52bdc8 100644 --- a/radicle-cli/examples/workflow/5-patching-maintainer.md +++ b/radicle-cli/examples/workflow/5-patching-maintainer.md @@ -16,6 +16,13 @@ $ rad remote add z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --name bob --s The contributor's changes are now visible to us. ``` +$ rad inbox --sort-by id +╭──────────────────────────────────────────────────────────────────────╮ +│ heartwood │ +├──────────────────────────────────────────────────────────────────────┤ +│ 1 ● issue flux capacitor underpowered d060989 opened now │ +│ 2 ● patch Define power requirements a99d55e opened now │ +╰──────────────────────────────────────────────────────────────────────╯ $ git branch -r bob/patches/a99d55e5958a8c52ff7efbc8ff000d9bbdac79c7 rad/master diff --git a/radicle-cli/src/commands.rs b/radicle-cli/src/commands.rs index 7668cabc2..3ea9f0b32 100644 --- a/radicle-cli/src/commands.rs +++ b/radicle-cli/src/commands.rs @@ -20,6 +20,8 @@ pub mod rad_fork; pub mod rad_help; #[path = "commands/id.rs"] pub mod rad_id; +#[path = "commands/inbox.rs"] +pub mod rad_inbox; #[path = "commands/init.rs"] pub mod rad_init; #[path = "commands/inspect.rs"] diff --git a/radicle-cli/src/commands/inbox.rs b/radicle-cli/src/commands/inbox.rs new file mode 100644 index 000000000..08f656cfb --- /dev/null +++ b/radicle-cli/src/commands/inbox.rs @@ -0,0 +1,379 @@ +use std::ffi::OsString; +use std::process; + +use anyhow::anyhow; + +use localtime::LocalTime; +use radicle::issue::Issues; +use radicle::node::notifications; +use radicle::node::notifications::*; +use radicle::patch::Patches; +use radicle::prelude::{Profile, RepoId}; +use radicle::storage::RefUpdate; +use radicle::storage::{ReadRepository, ReadStorage}; +use radicle::{cob, Storage}; + +use term::Element as _; + +use crate::terminal as term; +use crate::terminal::args; +use crate::terminal::args::{Args, Error, Help}; + +pub const HELP: Help = Help { + name: "inbox", + description: "Manage your Radicle notifications inbox", + version: env!("CARGO_PKG_VERSION"), + usage: r#" +Usage + + rad inbox [