Add --post-count option

This commit is contained in:
Marc Plano-Lesay 2025-05-02 13:05:40 +10:00
parent bdcc0def42
commit a91e243ecc
Signed by: kernald
GPG key ID: 66A41B08CC62A6CF
3 changed files with 20 additions and 3 deletions

View file

@ -1,5 +1,6 @@
use chrono::{DateTime, TimeZone, Utc};
use color_eyre::eyre::{Result, WrapErr};
use roux::util::FeedOption;
use roux::User;
use serde::{Deserialize, Serialize};
@ -21,10 +22,20 @@ impl RedditClient {
}
/// Fetch submissions for a user
pub async fn fetch_user_submissions(&self, username: &str) -> Result<Vec<RedditPost>> {
///
/// # Arguments
///
/// * `username` - The Reddit username to fetch submissions for
/// * `post_count` - The maximum number of posts to fetch
pub async fn fetch_user_submissions(
&self,
username: &str,
post_count: u32,
) -> Result<Vec<RedditPost>> {
let user = User::new(username);
let feed_option = FeedOption::new().limit(post_count);
let submissions = user
.submitted(None)
.submitted(Some(feed_option))
.await
.context(format!("Failed to fetch submissions for user {}", username))?;