forked from
nonbinary.computer/jacquard
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;
6
7#[derive(Parser, Debug)]
8#[command(author, version, about = "Create a simple post")]
9struct Args {
10 /// Handle (e.g., alice.bsky.social) or DID
11 input: CowStr<'static>,
12
13 /// App Password
14 password: CowStr<'static>,
15
16 /// Post text
17 #[arg(short, long)]
18 text: String,
19}
20
21#[tokio::main]
22async fn main() -> miette::Result<()> {
23 let args = Args::parse();
24
25 let (session, auth) =
26 MemoryCredentialSession::authenticated(args.input, args.password, None).await?;
27 println!("Signed in as {}", auth.handle);
28
29 let agent: Agent<_> = Agent::from(session);
30
31 // Create a simple text post using the Agent convenience method
32 let post = Post {
33 text: CowStr::from(args.text),
34 created_at: Datetime::now(),
35 embed: None,
36 entities: None,
37 facets: None,
38 labels: None,
39 langs: None,
40 reply: None,
41 tags: None,
42 extra_data: Default::default(),
43 };
44
45 let output = agent.create_record(post, None).await?;
46 println!("✓ Created post: {}", output.uri);
47
48 Ok(())
49}