Goods, kinda like npm for cargo


#1

https://github.com/schisma/goods

This is goods, a small CLI tool to add dependencies to a Cargo.toml automatically, kinda like npm.
You can install it by running (sudo) npm i -g goods and then running gds install cargopackage in a directory where a Cargo file is present. Goods automatically checks if the crate even exists by looking through the GitHub index.

That being said, the project is at its very start, so if you have suggestions of any kind or maybe improvements, post them here or create a PR on GitHub!


#2

I really like the idea, thuogh it would be nice if this sort of thing was built into Cargo itself, reducing the extra dependency.


#3

I you want this to get any use, you’ll want to rewrite it in Rust and make it a cargo subcommand.


#4

@darthdeus @birkenfeld Makes sense, but I don’t think my Rust is good enough to properly fabricate something there. (Which is why I wrote it in Node ;))


#5

It shouldn’t be too difficult, given that Cargo already knows how to handle .toml files. You wouldn’t have to write much code, probably just plug in at the right places.


#6

There’s this though! https://github.com/killercup/cargo-edit


#7

AFAIK, it doesn’t have to be written in rust to be a cargo subcommand-- if it has a binary named “cargo-something” and you have it installed in your $PATH, you can then run it as if it were a cargo subcommand, that is, with cargo something.

This is documented on the cargo wiki :smile:


#8

I realize that, but I for one wouldn’t want to have to install node.js just to get something that’s supposed to be part of the Rust ecosystem.


#9

That’s your choice, of course. I just wanted to point out that it wasn’t a technical limitation of the cargo subcommand system :smile:


#10

If you have the time and skills, you’re free to replicate the functionality within Rust, of course!


#11

Well, this doesn’t look too complicated, so it could also be a nice project to get deeper into Rust for you :slight_smile:


#12

That’s actually not too bad of an idea!


#13

It would be nice to have a flag to cargo install subcommand, like cargo install --save.


#14

It would be nice to have a flag to cargo install subcommand, like cargo install --save. @kstep

This is exactly what I was going to suggest. That matches the behavior of npm install --save (and likewise with other, similar tools). You might also think about using the Cargo manifest’s [dev-dependencies] section to do something like what you can do with npm install --save-dev.


#15

That’s exactly what was on my mind too.