mara: 'those comments seem very redundant'. true — the 16 pure-GET verbs all got the same 'transport error + stdout I/O' boilerplate, which just restates the Result<()> contract that's trivially derivable from the type. dropped # Errors from: assign, branches, close, comment_show, comments, diff, issue, labels, lint, list, milestone, pr, pr_reviews, subscription, timeline, tree_sha, view (17 files). kept on the 7 verbs that have a non-Forgejo failure surface worth documenting: - comment, comment_edit, issue_create, issue_edit — body input I/O via --body-file / stdin - pr_create — body input + --push shellout to git - attach::run_issue, attach::run_comment — explicit bail! on missing file net: 23 verbs touched in the original PR → 17 trimmed back to no-doc, 6 kept (with the 7th call being attach::run_comment in the same file). 38 tests still pass.
47 lines
1.4 KiB
Rust
47 lines
1.4 KiB
Rust
//! `subscription [--watch|--ignore|--unwatch] [repo]` — get or set
|
|
//! the current user's watch subscription for a repo.
|
|
|
|
use anyhow::Result;
|
|
use clap::Args as ClapArgs;
|
|
use serde_json::{Value, json};
|
|
|
|
use crate::client::Client;
|
|
use crate::verbs::print_json;
|
|
|
|
#[derive(ClapArgs)]
|
|
pub struct Args {
|
|
/// Subscribe (watch the repo).
|
|
#[arg(long, group = "action")]
|
|
watch: bool,
|
|
/// Mute (mark ignored).
|
|
#[arg(long, group = "action")]
|
|
ignore: bool,
|
|
/// Unsubscribe (clear watch + ignore).
|
|
#[arg(long, group = "action")]
|
|
unwatch: bool,
|
|
}
|
|
|
|
pub fn run(client: &Client, args: Args) -> Result<()> {
|
|
let repo = client.repo();
|
|
if args.unwatch {
|
|
client.delete(&format!("/repos/{repo}/subscription"), None)?;
|
|
println!("unsubscribed");
|
|
return Ok(());
|
|
}
|
|
if args.watch || args.ignore {
|
|
let (subscribed, ignored) = if args.ignore { (false, true) } else { (true, false) };
|
|
let resp = client.post_json(
|
|
&format!("/repos/{repo}/subscription"),
|
|
&json!({ "subscribed": subscribed, "ignored": ignored }),
|
|
)?;
|
|
return print_json(&json!({
|
|
"subscribed": resp.get("subscribed"),
|
|
"ignored": resp.get("ignored"),
|
|
}));
|
|
}
|
|
let resp: Value = client.get_json(&format!("/repos/{repo}/subscription"))?;
|
|
print_json(&json!({
|
|
"subscribed": resp.get("subscribed"),
|
|
"ignored": resp.get("ignored"),
|
|
}))
|
|
}
|