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