Skip to content

Commit

Permalink
Add DID verify functionality to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
sgreenbury committed Jul 31, 2023
1 parent 8c312bb commit 5ba7089
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions trustchain-cli/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ fn cli() -> Command {
.subcommand(
Command::new("verify")
.about("Verifies a DID.")
.arg(arg!(-v - -verbose).action(ArgAction::SetTrue))
.arg(arg!(-d --did <DID>).required(true)),
.arg(arg!(-d --did <DID>).required(true))
.arg(arg!(-t --root_event_time <ROOT_EVENT_TIME>).required(false))
),
)
.subcommand(
Expand Down Expand Up @@ -141,6 +141,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
to_string_pretty(&res_meta).expect("Cannot convert to JSON.")
);
}
Some(("verify", sub_matches)) => {
let did = sub_matches.get_one::<String>("did").unwrap();
let root_event_time = match sub_matches.get_one::<String>("root_event_time") {
Some(time) => time.parse::<u32>().unwrap(),
None => cli_config().root_event_time,
};
let did_chain = TrustchainAPI::verify(did, root_event_time, &verifier).await?;
println!("{did_chain}");
}
_ => panic!("Unrecognised DID subcommand."),
}
}
Expand Down

0 comments on commit 5ba7089

Please sign in to comment.