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

mommy demands begging~ #87

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Unreleased

Nothing Yet!
* mommy allows her users to [beg](https://github.com/Gankra/cargo-mommy/pull/87)


# Version 0.3.1 (2023-11-20)
Expand Down
84 changes: 84 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ default = ["thirsty", "yikes"]

thirsty = []
yikes = []
beg = []

[dependencies]
anyhow = "1.0.83"
cfg-if = "1.0.0"
fastrand = "1.8.0"
home = "0.5.9"

[build-dependencies]
serde = { version = "1.0.151", features = ["derive"] }
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ So if you set `CARGO_MOMMYS_ROLES="daddy"`, `CARGO_MOMMYS_PRONOUNS="his/their"`,

And so on~ 💓

## Begging

The `beg` feature (disabled by default) will allow Mommy to decline your request if you are not polite enough~ 💗

In order to beg for Mommy, invoke `cargo mommy please x` instead of `cargo mommy x`.

Begging is an independent feature that respects every mood, spicy or not 🥰

[Learn more about how to beg for Mommy](https://faultlore.com/cargo-mommy/book/customize/begging.html)



Expand Down
1 change: 1 addition & 0 deletions book/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ By default mommy is kind to her little girl, but she can become anything you wan
* [I want mommy to invoke mommy with more than cargo](./customize/not-just-cargo.md)
* [I want mommy to sdsdfdsfdfsd me (enabling nsfw features)](./customize/nsfw.md)
* [I never want mommy to sdsdfdsfdfsd me (compiling out all nsfw features)](./customize/never-nsfw.md)
* [I want to beg for mommy](./customize/begging.md)
1 change: 1 addition & 0 deletions book/src/customize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ By default mommy is kind to her little girl, but she can become anything you wan
* [I want mommy to invoke mommy with more than cargo](./not-just-cargo.md)
* [I want mommy to sdsdfdsfdfsd me (enabling nsfw features)](./nsfw.md)
* [I never want mommy to sdsdfdsfdfsd me (compiling out all nsfw features)](./never-nsfw.md)
* [I want to beg for mommy](./begging.md)
72 changes: 72 additions & 0 deletions book/src/customize/begging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Begging

Daring, are we~? ❤️

Mommy wants to see you beg~ the question is, how much?

## I DONT WANT TO BE HERE

No worries! Mommy disabled begging by default~ 💖 It's not even included in the binary unless you opt into it~

Here are [other ways you can customize](https://faultlore.com/cargo-mommy/book/customize/index.html)

## I want to Beg

You can enable begging by enabling all features

```
cargo install cargo-mommy --all-features
```

Or if you want to manage begging and spiciness independently, you can specify the features directly


```
cargo install cargo-mommy --features thirsty beg
```

## How to Beg

In order to beg for Mommy, invoke `cargo mommy please x` instead of `cargo mommy x`.

Begging makes Mommy very happy~! 💖

Do you prefer a more stubborn Mommy? 😾 You can always beg harder by chaining multiple begs together (`cargo mommy please please please x`), or using all caps (`cargo mommy PLEASE x`), or doing a mixture of both~ 💞


## Configuration


Begging is an independent feature that respects every mood, spicy or not 🥰

Mommy will consider the following environmental variables~

* `CARGO_MOMMYS_BEG_HALF_LIFE` ⏱️
* Mommy won't require you to beg if your previous successful beg was recent enough. This is the half-life (in seconds) of each successful beg.
* **Default:** 0 (a value of 0 turns off Mommy's want for begging)
* **Example:** A value of 300 (5 minutes), will allow the next non-beg a 74% chance of passing at 2 minutes, 50% at 5 minutes, and 25% at 10 minutes.
* `CARGO_MOMMYS_BEG_STUBBORN_CHANCE` 😾
* If you fail to beg when asked, then this is the percent chance that Mommy will hold a grudge and each subsequent beg might not be good enough. After a beg is finally good enough, the grudge ends.
* **Default:** 15

## Customize your Begging Trigger

Mommy keeps track of the previous time you begged using a file in `CARGO_HOME`, that being `.cargo/MOMMY-PLEASE.time` ⏱️

You can tell Mommy that you're begging in a round-about way by touching or updating the last modified time of this file. Mommy will update this file herself when you beg to her directly, but you can also drive it externally.

For example, you could set up an AutoHotKey script to a macro button on your keyboard, or write your own code or process to drive the file from other real-world interactions.

Note that a recent beg detected this way only counts as a single lowercase `please`. If Mommy is being especially stubborn 😾, the best way to break out of her grudge might be a proper and direct `cargo mommy please PLEASE PLEASE`.


## I want to Stop Begging

You can set `CARGO_MOMMYS_BEG_HALF_LIFE` to 0 ⏱️, and Mommy will not care to see you beg.

If you are stuck in a grudge, you can set `CARGO_MOMMYS_BEG_STUBBORN_CHANCE` to a lower value or 0 😾.

Make sure you relaunch your interface to capture the updated environment.

You can also run ```cargo uninstall cargo-mommy``` to remove your installation with begging enabled, and ```cargo install cargo-mommy``` without all features to return to Mommy without the begging. It's okay honey, begging can be hard~ ❤️

70 changes: 50 additions & 20 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
use std::collections::BTreeMap;
use std::env;
use std::fmt::Write;
use std::fs;
use std::fs::File;
use std::io::Write as FileWrite;
use std::ops::Range;
use std::path::Path;

Expand Down Expand Up @@ -50,7 +51,12 @@ struct Mood {
positive: Vec<String>,
negative: Vec<String>,
overflow: Vec<String>,

#[cfg(feature = "beg")]
beg_first: Vec<String>,
#[cfg(feature = "beg")]
did_not_beg: Vec<String>,
#[cfg(feature = "beg")]
must_beg_more: Vec<String>,
#[serde(default)]
spiciness: Spiciness,
}
Expand Down Expand Up @@ -88,6 +94,9 @@ fn main() {
if var.spiciness > Spiciness::CONFIGURED {
continue;
}
if name.starts_with("beg") && !cfg!(feature = "beg") {
continue
}
var.index = i;
i += 1;

Expand Down Expand Up @@ -150,6 +159,21 @@ fn main() {
for response in &mood.overflow {
parse_response(response, &mut responses)
}
#[cfg(feature = "beg")]
{
let _ = write!(responses, "], beg_first: &[");
for response in &mood.beg_first {
parse_response(response, &mut responses)
}
let _ = write!(responses, "], did_not_beg: &[");
for response in &mood.did_not_beg {
parse_response(response, &mut responses)
}
let _ = write!(responses, "], must_beg_more: &[");
for response in &mood.must_beg_more {
parse_response(response, &mut responses)
}
}
let _ = write!(responses, "] }},");
}

Expand All @@ -158,23 +182,29 @@ fn main() {
let emote_idx = config.vars["emote"].index;
let pronoun_idx = config.vars["pronoun"].index;
let role_idx = config.vars["role"].index;

fs::write(
dest_path,
format!(
r"
static CONFIG: Config<'static> = Config {{
vars: &[{vars}],
moods: &[{responses}],
}};
static MOOD: &Var<'static> = &CONFIG.vars[{mood_idx}];
static EMOTE: &Var<'static> = &CONFIG.vars[{emote_idx}];
static PRONOUN: &Var<'static> = &CONFIG.vars[{pronoun_idx}];
static ROLE: &Var<'static> = &CONFIG.vars[{role_idx}];
"
),
)
.unwrap();
let beg_half_life_idx = config.vars["beg_half_life"].index;
let beg_stubborn_chance_idx = config.vars["beg_stubborn_chance"].index;

let mut file = File::create(&dest_path).unwrap();
let f = format!(r"
static CONFIG: Config<'static> = Config {{
vars: &[{vars}],
moods: &[{responses}],
}};
static MOOD: &Var<'static> = &CONFIG.vars[{mood_idx}];
static EMOTE: &Var<'static> = &CONFIG.vars[{emote_idx}];
static PRONOUN: &Var<'static> = &CONFIG.vars[{pronoun_idx}];
static ROLE: &Var<'static> = &CONFIG.vars[{role_idx}];
");
File::write_all(&mut file, f.as_bytes()).unwrap();

if cfg!(feature = "beg") {
let f = format!(r"
static BEG_HALF_LIFE: &Var<'static> = &CONFIG.vars[{beg_half_life_idx}];
static BEG_STUBBORN_CHANCE: &Var<'static> = &CONFIG.vars[{beg_stubborn_chance_idx}];
");
File::write_all(&mut file, f.as_bytes()).unwrap();
}

println!("cargo:rerun-if-changed=responses.json");
}
}
Loading