Code Monkey home page Code Monkey logo

cargo-mommy's People

Contributors

5225225 avatar arslee07 avatar bwo avatar gankra avatar isaacg1 avatar lymkwi avatar mcy avatar mindpersephone avatar nanoqsh avatar nilstrieb avatar orhun avatar poopsicles avatar trinity-1686a avatar vixietsq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cargo-mommy's Issues

mommy should let you specify the directory for "i mean" copies

mommy tries to copy itself to the same directory it's already in when using "i mean", but this won't work when it doesn't have permission to write to that directory (most notably, when installed via Nix). I should be able to tell mommy what directory to use for aliases (e.g. with an env var).

Also I noticed mommy copies her binary instead of symlinking. That seems like it will cause trouble when updating mommy.

support multiple littles cofronting

mew, not sure if it's abdl or plurality related (or both) but wei have multiple littles sometimes blending at the same time. would a pull request for multiple littles be welcome? also our caregiver also needs support sometime.

mommy should tell me her version

I know it's rude to ask mommy how old she is, but I'd like a way to ask her what her version is (and maybe a list of her moods).

mommy shouldn't uses envvars with spaces in the names when her role is many words~

If you use the i mean feature to convert mommy into a binary which has a space in its name, it will correctly infer the correct role up to the point where it needs to find the names of environment variables to fetch information from.

In a hypothetical scenario, I was able to have it spit this:

/ ~ cargo mommy i mean "big sis"
mommy is now big sis~
/ ~ CARGO_BIG_SISS_LITTLE=TEST cargo "big sis" --help
[ SNIP ]
SCREAMING_ROLE: BIG SIS
SCREAMING_ROLE: BIG SIS
SCREAMING_ROLE: BIG SIS
SCREAMING_ROLE: BIG SIS
SCREAMING_ROLE: BIG SIS
big sis loves her cute little girl~ ๐Ÿ’—

IMO, the correct behaviour should be that spaces be replaced with "_" when converting to screaming_role.

[mood] ability to strip moods from the binary at build time

I'm not 100% sure how i'd want it to be impl the interface for it, but some people are concerned about the more spicy mood strings being in the binary, so it would be nice to have a way to maybe do like --no-default-features and have only chill mode.

The only place that really needs to change is here:

https://github.com/Gankra/cargo-mommy/blob/aa7801b3a69d789d52a72436c94cfdd8c6fe6e12/build.rs#L40C15-L56

break up the string formatting into several iterative steps, then disable the ones you don't want in the binary (forget if build.rs makes reading features messy).

add better docs for how to use env-vars

Lots of people aren't terribly familiar with how to use env-vars, so having some more explicit guides on how to put stuff in rcfiles persistently, example configs, what to do on windows, etc. would be great.

Reconcile main branch with crates.io

Currently crates.io has version 0.2.1 and the main branch has version 0.2.0. Probably the modular-mommy branch containing the 0.2.1 release should be merged into main?

mommy can be run every time you run cargo~

i promised ages ago to document this and then i never did lmao

here is a dump of my ~/.profile, which makes e.g. cargo build act as if you'd run cargo mommy build

# mommy loves you~
cargo() {
    case "$1" in
    +*) toolchain=$1
        shift
        command cargo "$toolchain" mommy "$@"
        ;;
    *) command cargo mommy "$@";;
    esac
}

make mommy have more to say

y'all keep submitting optimizations but what the world really needs is a bigger pool of responses from mommy:

{
"chill": {
"positive": [
"*pets your head*",
"*gives you scritches*",
"you're such a smart cookie~",
"that's a good AFFECTIONATE_TERM~",
"MOMMYS_ROLE thinks MOMMYS_PRONOUN little AFFECTIONATE_TERM earned a big hug~",
"good AFFECTIONATE_TERM~\nMOMMYS_ROLE's so proud of you~",
"aww, what a good AFFECTIONATE_TERM~\nMOMMYS_ROLE knew you could do it~",
"you did it~!",
"MOMMYS_ROLE loves you~",
"*gives you a sticker*"
],
"negative": [
"MOMMYS_ROLE believes in you~",
"don't forget to hydrate~",
"aww, you'll get it next time~",
"do you need MOMMYS_ROLE's help~?",
"MOMMYS_ROLE still loves you no matter what~",
"oh no did MOMMYS_ROLE's little AFFECTIONATE_TERM make a big mess~?",
"MOMMYS_ROLE knows MOMMYS_PRONOUN little AFFECTIONATE_TERM can do better~",
"MOMMYS_ROLE still loves you~",
"just a little further, sweetie~"
]
},

standalone "mommy" binary?

Many people have asked, it might be reasonable to have the cargo-mommy package include two binaries: cargo-mommy (the current one) and mommy (a new one). The mommy binary would behave more like time or whatever, in that it would execute all the arguments that follow, without any notion of "re-invoking cargo". cargo mommy check would be basically equivalent to mommy cargo check, i think.

If we want to do this, the bulk of main.rs should be hoisted into a new lib.rs, as both binaries would share most logic.

They would basically differ in the cli logic in main.rs:

cargo-mommy/src/main.rs

Lines 45 to 168 in 0ec1736

// Interpret the argument as a path so we can manipulate it~
let first_arg = arg_iter.next();
let bin_path = env::current_exe()
.unwrap_or_else(|_| std::path::PathBuf::from(first_arg.unwrap_or_default()));
// Get the extensionless-file name, and parse it case-insensitively~
let bin_name = bin_path
.file_stem()
.unwrap_or_default()
.to_string_lossy()
.to_lowercase();
let true_role = if let Some((_path, role)) = bin_name.rsplit_once("cargo-") {
role.to_owned()
} else {
// If something messed up is going on "mommy" will always take care of it~
"mommy".to_owned()
};
let cargo = env::var(format!("CARGO_{}S_ACTUAL", true_role.to_uppercase()))
.or_else(|_| env::var("CARGO"))
.unwrap_or_else(|_| "cargo".to_owned());
// Check if someone has told mommy to keep calling herself~
// Mommy loves you, darlings, but she can't keep running forever~
let mut new_limit = 1;
if let Ok(limit) = env::var(RECURSION_LIMIT_VAR) {
if let Ok(n) = limit.parse::<u8>() {
if n > RECURSION_LIMIT {
let mut response = select_response(&true_role, &rng, ResponseType::Overflow);
match &mut response {
Ok(s) | Err(s) => {
*s += "\nyou didn't set CARGO to something naughty, did you?\n"
}
}
pretty_print(response);
return Ok(2);
} else {
new_limit = n + 1;
}
}
}
// *GASPS FOR BREATH*
//
// *INHALES DESPERATELY*
//
// cargo subcommands when run as "cargo blah" get the "blah" argument passed to themselves
// as the *second* argument. However if we are invoked directly as "cargo-blah" we won't
// have that extra argument! So if there's a second argument that is "mommy" (or whatever)
// we pop off that redundant copy before forwarding the rest of the args back to "cargo ...".
// if we don't do this, we'll infinitely recurse into ourselves by re-calling "cargo mommy"!
// (note that it *is* supported to do `cargo mommy mommy` and get two messages, although I
// believe we do this, `cargo-mommy mommy` will still only get you one message).
if arg_iter.peek().map_or(false, |arg| arg == &true_role) {
let _ = arg_iter.next();
}
// *WHEEZES*
//
// *PANTS FOR A MINUTE*
//
// Ok so now we want to detect if the invocation looked like "cargo mommy i mean daddy"
// if it *does* we want to copy ourselves to rename cargo-mommy to cargo-daddy. To make this
// simpler, collect the args into a vec so we can peek more than one element.
//
// ...
//
// ~
let mut args: Vec<_> = arg_iter.collect();
{
// We speculate the "i mean" part so that can easily discard it
// in the case of "cargo mommy i mean mommy", making the execution
// equivalent to "cargo mommy mommy". Not popping off the extra
// "mommy" let "cargo mommy i mean mommy i mean mommy" work right~
let new_role = args.get(2);
let mean = args.get(1) == Some(&"mean".to_owned());
let i = args.get(0) == Some(&"i".to_owned());
if i && mean {
if let Some(new_role) = new_role.cloned() {
// Ok at this point we're confident we got "i mean <new_role>"
// so definitely consume those arguments~
args.drain(..2);
// If the new role is the same as before, they typed something like
// "cargo mommy i mean mommy test" so we don't need to do anything~
if new_role != true_role {
if let Some(parent) = bin_path.parent() {
let new_bin_name = format!("cargo-{new_role}");
let mut new_bin_path = parent.join(new_bin_name);
if let Some(ext) = bin_path.extension() {
new_bin_path.set_extension(ext);
}
if let Err(e) = std::fs::copy(bin_path, new_bin_path) {
Err(format!(
"{role} couldn't copy {pronoun}self...\n{e:?}",
role = ROLE.load(&true_role, &rng)?,
pronoun = PRONOUN.load(&true_role, &rng)?,
))?
} else {
// Just exit immediately on success, don't try to get too clever here~
eprintln!("{true_role} is now {new_role}~");
return Ok(0);
}
} else {
Err(format!(
"{role} couldn't copy {pronoun}self...\n(couldn't find own parent dir)",
role = ROLE.load(&true_role, &rng)?,
pronoun = PRONOUN.load(&true_role, &rng)?,
))?;
}
}
}
}
}
// Time for mommy to call cargo~
let mut cmd = std::process::Command::new(cargo);
cmd.args(args)
.env(RECURSION_LIMIT_VAR, new_limit.to_string());
let status = cmd.status()?;
let code = status.code().unwrap_or(1);
if is_quiet_mode_enabled(cmd.get_args()) {
return Ok(code);
}

How should we behave on Ctrl+C?

I was thinking about #28 and checked out how cargo mommy fuzz works at the moment. A fuzzing failure works, since it exits with nonzero status, but fuzzers typically run indefinitely (or until you get bored, rather. Unless you set a timeout), so you ^C them, which leads mommy to have no output.

Not outputting anything for a normal command seems fine (unless you wanted to make a quip about how impatient the user is, which would be a third response type I think), but at least for a fuzzer which generally always will be exit with ^C, not doing anything doesn't seem great. Treating it as a success would be fine?

Making this issue mainly to get feedback on how we should act here, I have no firm opinions.

Regex filtering through environment variables for responses?

I have extremely severe Tourette's Syndrome, and almost all of my triggers are extremely common, and cause me great physical pain through motor tics (taking the form of painful twitching). Unfortunately, some of my triggers are in the current database of responses for certain moods, so I can't exactly use the full extent of cargo-mommy's features, without editing responses.json. Thankfully, if cargo-mommy supported regexes (with hex escapes so that I don't have to type my triggers, since that would also trigger me) for filtering out certain responses via an environment variable, all I'd have to do is set an environment variable in my .bashrc or whatever, and cargo-mommy would be safe for me to use. Sadly, I don't have much experience with the Rust ecosystem, so I have no idea what crates would be best for this, or how to implement this effectively.

mommy confused her pronouns a bit~

This line in the thirsty, positive responses doesn't work if one changes the default pronoun:

                "give {pronoun} a kiss~",

With the default pronoun of "her", it reads "give her a kiss", which works. But if one changes the pronoun to "their", it reads "give their a kiss". If one changes the pronoun to "his", it reads "give his a kiss". "their" and "his" are the two alternative pronouns mentioned in the README, so they should be supported.

The problem arises from the fact that "her" is used elsewhere as a dependent genitive pronoun, corresponding to "his" and "their", but is used here as an accusative pronoun, corresponding to "him" and "them".

To fix this, I think it would be easiest to say that "her" should always be used in parallel with "their" and "his", in the dependent genitive case, and to change this response to

                "give {role} a kiss~",

e.g. "give mommy a kiss~".

I hate it.

10/10. One of the programs ever written and I hate it with every fibre of my being. And am currently installing it on every computer I own. 10/10.

mommy needs some tests~

The behaviour of cargo-mommy is legitimately getting so complex that an actual CI/test-suite would probably be a good idea. I am always inclined towards using something like cargo-insta for snapshot testing rendered outputs, although I'm not sure the codebase is well-factored for that kind of thing.

...

~

Some handling of +toolchain syntax

I've setup an alias cargo="cargo mommy", sadly when doing something like cargo +nightly check, cargo tells me

error: no such command: `+nightly`

	Cargo does not handle `+toolchain` directives.
	Did you mean to invoke `cargo` through `rustup` instead?

and mommy tells me I can do better. I'd very much like to, but I don't think I can

Would a standalone binary work the same or better than a cargo extension?

The more I've been thinking, the more I think that this doesn't actually need to a cargo extension. It doesn't get much from it at all. Although this probably is just a side product of wanting to learn how cargo extensions work, I think it's done it's job for that use case. I can see one problem stemming from converting this to a standalone binary: people may try to use it in contexts outside of the rust compiler, and that means any 'compiling'-specific responses may not make sense, which I think would be quite sad and restrictive.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.