Skip to content
13 changes: 13 additions & 0 deletions crates/cccc-cli/src/args/messaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,19 @@ pub struct TailArgs {
pub follow: bool,
}

#[derive(Debug, Args)]
pub struct InboxSummaryArgs {
/// Target Group ID; omit to use the current Group.
#[arg(long = "group")]
pub group_id: Option<String>,
/// Inclusive original-Mail timestamp boundary (RFC3339, not in the future).
#[arg(long)]
pub cutoff: String,
/// Author identity: user or the Group's Foreman.
#[arg(long, default_value = "user")]
pub by: String,
}

#[derive(Debug, Args)]
pub struct InboxArgs {
/// Target Group ID; omit to use the current Group.
Expand Down
6 changes: 4 additions & 2 deletions crates/cccc-cli/src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub use integrations::{
SpaceCredentialAction, SpaceJobsAction,
};
pub use messaging::{
CancelReplyArgs, ConnectArgs, DeliverArgs, InboxArgs, LedgerAction, LedgerArgs, ReplyArgs,
SendArgs, TailArgs, TrackedSendArgs,
CancelReplyArgs, ConnectArgs, DeliverArgs, InboxArgs, InboxSummaryArgs, LedgerAction,
LedgerArgs, ReplyArgs, SendArgs, TailArgs, TrackedSendArgs,
};

use clap::{Args, Parser, Subcommand, ValueEnum};
Expand Down Expand Up @@ -137,6 +137,8 @@ pub enum CommandKind {
Space(SpaceArgs),
/// Read and consume the next unread Mail batch for an actor.
Inbox(InboxArgs),
/// Summarize current awaiting Mail across a Group without consuming it.
InboxSummary(InboxSummaryArgs),
/// Read cached same-account and Group connection directories. Does not connect or start Actors.
Connect(ConnectArgs),
/// Send a message to a Group.
Expand Down
19 changes: 17 additions & 2 deletions crates/cccc-cli/src/commands/messaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use cccc_core::HomeLayout;
use serde_json::json;

use crate::args::{
CancelReplyArgs, ConnectArgs, DeliverArgs, InboxArgs, LedgerAction, LedgerArgs, ReplyArgs,
SendArgs, TailArgs, TrackedSendArgs,
CancelReplyArgs, ConnectArgs, DeliverArgs, InboxArgs, InboxSummaryArgs, LedgerAction,
LedgerArgs, ReplyArgs, SendArgs, TailArgs, TrackedSendArgs,
};
use crate::commands::common::{call, group, print};

Expand Down Expand Up @@ -209,6 +209,21 @@ pub async fn tail(client: &DaemonClient, home: &HomeLayout, args: TailArgs) -> R
}
}

pub async fn inbox_summary(
client: &DaemonClient,
home: &HomeLayout,
args: InboxSummaryArgs,
) -> Result<()> {
let group_id = group(home, args.group_id)?;
let response = call(
client,
"inbox_summary",
json!({"group_id":group_id,"cutoff":args.cutoff,"by":args.by}),
)
.await?;
print(response)
}

pub async fn inbox(client: &DaemonClient, home: &HomeLayout, args: InboxArgs) -> Result<()> {
let group_id = group(home, args.group_id)?;
let response = call(
Expand Down
3 changes: 3 additions & 0 deletions crates/cccc-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ async fn main() -> Result<()> {
}
Some(CommandKind::Tail(args)) => commands::messaging::tail(&client, &home, args).await,
Some(CommandKind::Inbox(args)) => commands::messaging::inbox(&client, &home, args).await,
Some(CommandKind::InboxSummary(args)) => {
commands::messaging::inbox_summary(&client, &home, args).await
}
Some(CommandKind::Ledger(args)) => commands::messaging::ledger(&client, &home, args).await,
Some(CommandKind::Daemon { action }) => daemon(action, home, &client).await,
Some(CommandKind::Runtime { action }) => runtime(&client, action).await,
Expand Down
Loading
Loading