#rust #cargo-auto

cargo_auto_lib

Library crate for common tasks when building rust projects. Intended for use with cargo-auto: automation tasks written in Rust language.

1 unstable release

0.7.22 Sep 18, 2021
0.7.19 Aug 27, 2021
0.6.1 Aug 14, 2021
0.5.1 Aug 14, 2021
0.1.15 Aug 13, 2021
Download history 71/week @ 2021-08-08 146/week @ 2021-08-15 32/week @ 2021-08-22 6/week @ 2021-08-29 8/week @ 2021-09-12 24/week @ 2021-09-19 16/week @ 2021-09-26 32/week @ 2021-10-03 16/week @ 2021-10-10 16/week @ 2021-10-17

85 downloads per month

MIT license

73KB
1K SLoC

cargo_auto_lib

Library crate for common tasks when building rust projects. Intended for use with cargo-auto: automation tasks written in Rust language.
repository; version: 0.7.22 date: 2021-09-18 authors: Luciano Bestia

Lines in Rust code Lines in Doc comments Lines in Comments Lines in examples Lines in tests

crates.io Documentation crev reviews Lib.rs Licence Rust

Try it

In your rust project root directory (where the Cargo.toml is)
first install cargo-auto and generate a new helper project:

cargo install cargo-auto
cargo auto new with_lib

In a new editor open the generated directory automation_tasks_rs as an independent rust project. There is already this dependency in Cargo.toml:

cargo_auto_lib="0.7.*"

Preview the code and observe all the auto_* functions from cargo_auto_lib.
Example:

fn task_release() {
    auto_semver_increment_patch();
    auto_cargo_toml_to_md();
    auto_lines_of_code("");
    auto_build();
}

Go back to your main rust project.
Add markers to the beginning of README.md (don't copy the numbers 1 and 2):

1 [comment]: # (auto_cargo_toml_to_md start)
2 [comment]: # (auto_cargo_toml_to_md end)

Run (in your main rust project):

cargo auto release

With a little luck, it included the data of Cargo.toml into the README.md inside the markers:

auto_cargo_toml_to_md

based on simple functions

All the functions have extensive help/docs to describe how they work.
It is nice when you use a code editor with IntelliSense like VSCode.

Caveats

This crate will attempt to edit Cargo.toml. Unfortunately there's no great robust way right now to edit TOML file preserving formatting and comments and such, so right now I use just regex to do this. If you find that the heuristics don't work for you though please let me know and I'll try to check in a fix!

learn something new every day

I needed to copy large text into doc comments.
It means every line must get a prefix like ///.
In VSCode I selected the text, press
alt+shift+i Now I have multiple cursors on the end of every selected lines.
I press the key home And now I have multiple cursors on the beginning of every line.
I type (insert): ///
and it's done ! Great !

TODO

Automate badges for crates.io, doc.rs, lib.rs, license, crev review. Check if they exist and create badges.

cargo crev reviews and advisory

We leave in times of danger with supply chain attacks.
It is recommended to always use cargo-crev
to verify the trustworthiness of each of your dependencies.
Please, spread this info.
You can also read reviews quickly on the web. Example for the crate num-traits:
https://web.crev.dev/rust-reviews/crate/num-traits/

open-source free and free as a beer

My open-source projects are free and free as a beer (MIT license).
I just love programming.
But I need also to drink. If you find my projects and tutorials helpful,
please buy me a beer or two donating on my paypal.
You know the price of a beer in your local bar ;-)
So I can drink a free beer for your health :-)
Na zdravje !

Dependencies

~3–4.5MB
~102K SLoC

"Fa