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, 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::new()
33 .text(args.text)
34 .created_at(Datetime::now())
35 .build();
36 let output = agent.create_record(post, None).await?;
37 println!("✓ Created post: {}", output.uri);
38
39 Ok(())
40}