add timeline
This commit is contained in:
25
src/commands/feed.rs
Normal file
25
src/commands/feed.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use anyhow::Result;
|
||||
use serde_json::Value;
|
||||
|
||||
use super::auth;
|
||||
use crate::lexicons::app_bsky_feed;
|
||||
use crate::xrpc::XrpcClient;
|
||||
|
||||
/// Get timeline (JSON output)
|
||||
pub async fn timeline(limit: u32) -> Result<()> {
|
||||
let session = auth::refresh_session().await?;
|
||||
let pds = session.pds.as_deref().unwrap_or("bsky.social");
|
||||
let client = XrpcClient::new(pds);
|
||||
let limit_str = limit.to_string();
|
||||
|
||||
let body: Value = client
|
||||
.query_auth(
|
||||
&app_bsky_feed::GET_TIMELINE,
|
||||
&[("limit", &limit_str)],
|
||||
&session.access_jwt,
|
||||
)
|
||||
.await?;
|
||||
|
||||
println!("{}", serde_json::to_string_pretty(&body)?);
|
||||
Ok(())
|
||||
}
|
||||
@@ -16,3 +16,4 @@ pub mod oauth;
|
||||
pub mod setup;
|
||||
pub mod twofa;
|
||||
pub mod chat_post;
|
||||
pub mod feed;
|
||||
|
||||
25
src/main.rs
25
src/main.rs
@@ -197,6 +197,13 @@ enum Commands {
|
||||
#[command(alias = "v")]
|
||||
Version,
|
||||
|
||||
/// Feed commands
|
||||
#[command(alias = "f")]
|
||||
Feed {
|
||||
#[command(subcommand)]
|
||||
command: FeedCommands,
|
||||
},
|
||||
|
||||
/// Notification commands
|
||||
#[command(alias = "n")]
|
||||
Notify {
|
||||
@@ -268,6 +275,17 @@ enum TwoFaCommands {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum FeedCommands {
|
||||
/// Get timeline (JSON)
|
||||
#[command(alias = "tl")]
|
||||
Timeline {
|
||||
/// Max number of posts
|
||||
#[arg(short, long, default_value = "25")]
|
||||
limit: u32,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum NotifyCommands {
|
||||
/// List notifications (JSON)
|
||||
@@ -412,6 +430,13 @@ async fn main() -> Result<()> {
|
||||
Commands::Version => {
|
||||
println!("{}", env!("CARGO_PKG_VERSION"));
|
||||
}
|
||||
Commands::Feed { command } => {
|
||||
match command {
|
||||
FeedCommands::Timeline { limit } => {
|
||||
commands::feed::timeline(limit).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Commands::Notify { command } => {
|
||||
match command {
|
||||
NotifyCommands::List { limit } => {
|
||||
|
||||
Reference in New Issue
Block a user