Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom replacement comment text #59

Merged
merged 18 commits into from
Jun 25, 2023
Merged
6 changes: 5 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::things::ThingType;
use crate::things::{ThingType, LOREM_IPSUM};
use chrono::{DateTime, Utc};
use clap::Parser;
use std::path::PathBuf;
Expand Down Expand Up @@ -40,6 +40,10 @@ pub struct Config {
#[clap(long, env = "SHREDDIT_MAX_SCORE")]
pub max_score: Option<i64>,

/// Allows a user to specify a custom string as their comment replacement text
#[clap(short, long, env = "SHREDDIT_REPLACEMENT_COMMENT", default_value = LOREM_IPSUM)]
pub replacement_comment: String,

/// The User-Agent for Reddit API requests.
#[clap(
long,
Expand Down
3 changes: 1 addition & 2 deletions src/things/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use super::Shred;
use crate::{
cli::Config,
sources::{api::Api, gdpr::Gdpr},
things::LOREM_IPSUM,
};
use async_stream::stream;
use async_trait::async_trait;
Expand Down Expand Up @@ -112,7 +111,7 @@ impl Shred for Comment {

let params = HashMap::from([
("thing_id", self.fullname()),
("text", LOREM_IPSUM.to_string()),
("text", config.replacement_comment.to_string()),
]);

let res: EditResponse = client
Expand Down
2 changes: 1 addition & 1 deletion src/things/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ where
thing.delete(client, access_token, config).await;
}

static LOREM_IPSUM: &str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
pub static LOREM_IPSUM: &str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";

#[derive(Debug)]
pub enum ShredditError {
Expand Down