taskfast_cli/cmd/
dispute.rs1use clap::Parser;
9use serde_json::json;
10use uuid::Uuid;
11
12use super::{CmdError, CmdResult, Ctx};
13use crate::envelope::Envelope;
14
15use taskfast_client::map_api_error;
16
17#[derive(Debug, Parser)]
18pub struct Args {
19 pub task_id: String,
20}
21
22pub async fn run(ctx: &Ctx, args: Args) -> CmdResult {
23 let task_id = Uuid::parse_str(&args.task_id)
24 .map_err(|e| CmdError::Usage(format!("task id must be a UUID: {e}")))?;
25 let client = ctx.client()?;
26 let resp = match client.inner().get_task_dispute(&task_id).await {
27 Ok(v) => v.into_inner(),
28 Err(e) => return Err(map_api_error(e).await.into()),
29 };
30 Ok(Envelope::success(
31 ctx.environment,
32 ctx.dry_run,
33 json!({
34 "task_id": task_id.to_string(),
35 "dispute": resp,
36 }),
37 ))
38}