Add --post-count option
This commit is contained in:
parent
bdcc0def42
commit
a91e243ecc
3 changed files with 20 additions and 3 deletions
|
|
@ -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))?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue