A better Rust ATProto crate
1use clap::Parser;
2use jacquard::CowStr;
3use jacquard::api::app_bsky::feed::post::Post;
4use jacquard::client::{Agent, AgentSessionExt, MemoryCredentialSession};
5use jacquard::types::string::Datetime;
6use smol_str::SmolStr;
7
8#[derive(Parser, Debug)]
9#[command(author, version, about = "Create a simple post")]
10struct Args {
11 /// Handle (e.g., alice.bsky.social) or DID
12 input: CowStr<'static>,
13
14 /// App Password
15 password: CowStr<'static>,
16
17 /// Post text
18 #[arg(short, long)]
19 text: String,
20}
21
22#[tokio::main]
23async fn main() -> miette::Result<()> {
24 let args = Args::parse();
25
26 let (session, auth) =
27 MemoryCredentialSession::authenticated(args.input, args.password, None, None).await?;
28 println!("Signed in as {}", auth.handle);
29
30 let agent: Agent<_> = Agent::from(session);
31
32 // Create a simple text post using the Agent convenience method
33 let post = Post::<SmolStr>::new()
34 .text(args.text)
35 .created_at(Datetime::now())
36 .build();
37 let output = agent.create_record(post, None).await?;
38 println!("✓ Created post: {}", output.uri);
39
40 Ok(())
41}