rad-id-sync
This project has not described itself yet.
Brought by drakestapleton
rad-id-sync / src / main.rs
| 1 | use rad_id_sync::identity::IdentityAnchor; |
| 2 | use rad_id_sync::keys::sync_identity_keys; |
| 3 | use std::env; |
| 4 | |
| 5 | fn main() { |
| 6 | let args: Vec<String> = env::args().collect(); |
| 7 | let cmd = args.get(1).map(|s| s.as_str()).unwrap_or("status"); |
| 8 | |
| 9 | match cmd { |
| 10 | "status" => { |
| 11 | let anchor = match IdentityAnchor::load_or_init() { |
| 12 | Ok(a) => a, |
| 13 | Err(e) => { |
| 14 | eprintln!("Error loading identity anchor: {}", e); |
| 15 | std::process::exit(1); |
| 16 | } |
| 17 | }; |
| 18 | println!("=== Radicle Identity Anchor ==="); |
| 19 | println!("DID: {}", anchor.did); |
| 20 | println!("Name: {}", anchor.name); |
| 21 | println!("Type: {:?}", anchor.entity_type); |
| 22 | println!("Radicle Key: {}", anchor.primary_radicle_key.as_deref().unwrap_or("<none>")); |
| 23 | println!("SSH Key: {}", anchor.primary_ssh_key.as_deref().unwrap_or("<none>")); |
| 24 | println!("Last Synced: {}", anchor.last_synced_at); |
| 25 | println!("Key History: {} records", anchor.key_history.len()); |
| 26 | } |
| 27 | "sync" => { |
| 28 | let anchor = IdentityAnchor::load_or_init().expect("Failed to load anchor"); |
| 29 | let (_, report) = sync_identity_keys(anchor).expect("Sync failed"); |
| 30 | println!("{}", serde_json::to_string_pretty(&report).unwrap()); |
| 31 | } |
| 32 | "json" => { |
| 33 | let anchor = IdentityAnchor::load_or_init().expect("Failed to load anchor"); |
| 34 | let (_, report) = sync_identity_keys(anchor).expect("Sync failed"); |
| 35 | println!("{}", serde_json::to_string(&report).unwrap()); |
| 36 | } |
| 37 | _ => { |
| 38 | println!("Usage: rad-id-sync [status|sync|json]"); |
| 39 | } |
| 40 | } |
| 41 | } |