1use clap::Parser;
2use jacquard::api::sh_tangled::repo::Repo;
3use jacquard::client::{AgentSessionExt, BasicClient};
4use jacquard::types::string::AtUri;
5
6#[derive(Parser, Debug)]
7#[command(author, version, about = "Read a Tangled git repository record")]
8struct Args {
9 /// at:// URI of the repo record
10 /// Example: at://did:plc:xyz/sh.tangled.repo/3lzabc123
11 /// The default is the jacquard repository
12 #[arg(default_value = "at://did:plc:yfvwmnlztr4dwkb7hwz55r2g/sh.tangled.repo/3lzrya6fcwv22")]
13 uri: String,
14}
15
16#[tokio::main]
17async fn main() -> miette::Result<()> {
18 let args = Args::parse();
19
20 // Parse the at:// URI
21 let uri = AtUri::new(&args.uri)?;
22
23 // Create an unauthenticated agent for public record access
24 let agent = BasicClient::unauthenticated();
25
26 // Use Agent's get_record helper with the at:// URI
27 let response = agent.get_record::<Repo>(uri).await?;
28 let output = response.into_output()?;
29
30 println!("Tangled Repository\n");
31 println!("URI: {}", output.uri);
32 println!("Name: {}", output.value.name);
33
34 if let Some(desc) = &output.value.description {
35 println!("Description: {}", desc);
36 }
37
38 println!("Knot: {}", output.value.knot);
39 println!("Created: {}", output.value.created_at);
40
41 if let Some(source) = &output.value.source {
42 println!("Source: {}", source.as_str());
43 }
44
45 if let Some(spindle) = &output.value.spindle {
46 println!("CI Spindle: {}", spindle);
47 }
48
49 if let Some(labels) = &output.value.labels {
50 if !labels.is_empty() {
51 println!(
52 "Labels available: {}",
53 labels
54 .iter()
55 .map(|l| l.to_string())
56 .collect::<Vec<_>>()
57 .join(", ")
58 );
59 }
60 }
61
62 Ok(())
63}