CLI decode_token: use CBOR diagnostic format instead of pure JSON

This brings decoded TokenV4s in line with the format specified in NUT-00, especially around how byte array fields are handled.
This commit is contained in:
ok300
2024-09-07 23:23:35 +02:00
committed by thesimplekid
parent 03e1d88f3c
commit 65c1aea408
3 changed files with 15 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ use std::str::FromStr;
use anyhow::Result;
use cdk::nuts::Token;
use cdk::util::serialize_to_cbor_diag;
use clap::Args;
#[derive(Args)]
@@ -13,6 +14,6 @@ pub struct DecodeTokenSubCommand {
pub fn decode_token(sub_command_args: &DecodeTokenSubCommand) -> Result<()> {
let token = Token::from_str(&sub_command_args.token)?;
println!("{:}", serde_json::to_string_pretty(&token)?);
println!("{:}", serialize_to_cbor_diag(&token)?);
Ok(())
}