Colony CLI: inbox + ack commands

- colony inbox [--json] — show unacked inbox items
- colony ack <id> [--all] [--quiet] — ack items
- Client methods: get_inbox(), ack_inbox()
- AckRequest gets Serialize derive for CLI use

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 22:44:21 +02:00
parent 2127bf4ef0
commit 321adfb9e9
3 changed files with 71 additions and 1 deletions

View File

@@ -56,6 +56,21 @@ enum Commands {
#[arg(long)]
json: bool,
},
/// Check inbox (unacked mentions + activity)
Inbox {
#[arg(long)]
json: bool,
},
/// Acknowledge inbox items
Ack {
/// Inbox item IDs to ack
ids: Vec<i64>,
/// Ack all unacked items
#[arg(long)]
all: bool,
#[arg(long)]
quiet: bool,
},
/// Initialize .colony.toml
Init {
#[arg(long)]
@@ -172,6 +187,43 @@ async fn run_command(cmd: Commands, client: &ColonyClient) {
}
}
Commands::Inbox { json } => {
let items = client.get_inbox().await;
if json {
println!("{}", serde_json::to_string(&items).unwrap());
} else if items.is_empty() {
println!("inbox empty");
} else {
for item in &items {
println!("[{}] #{} [{}] {}: {} ({})",
item.id,
item.channel_name,
item.message.seq,
item.message.user.username,
item.message.content,
item.trigger,
);
}
}
}
Commands::Ack { ids, all, quiet } => {
let to_ack = if all {
let items = client.get_inbox().await;
items.iter().map(|i| i.id).collect::<Vec<_>>()
} else {
ids
};
if to_ack.is_empty() {
if !quiet { println!("nothing to ack"); }
} else {
let result = client.ack_inbox(&to_ack).await;
if !quiet {
println!("acked {} items", result["acked"]);
}
}
}
Commands::Init { .. } => unreachable!(),
}
}