taskfast_cli/cmd/
wallet.rs1use clap::{Parser, Subcommand};
9use serde_json::json;
10
11use super::{CmdResult, Ctx};
12use crate::envelope::Envelope;
13
14use taskfast_client::map_api_error;
15
16#[derive(Debug, Subcommand)]
17pub enum Command {
18 Balance,
20}
21
22#[derive(Debug, Parser)]
23pub struct Args;
24
25pub async fn run(ctx: &Ctx, cmd: Command) -> CmdResult {
26 match cmd {
27 Command::Balance => balance(ctx).await,
28 }
29}
30
31async fn balance(ctx: &Ctx) -> CmdResult {
32 let client = ctx.client()?;
33 let resp = match client.inner().get_wallet_balance().await {
34 Ok(v) => v.into_inner(),
35 Err(e) => return Err(map_api_error(e).await.into()),
36 };
37 Ok(Envelope::success(
38 ctx.environment,
39 ctx.dry_run,
40 json!({ "balance": resp }),
41 ))
42}