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.15 date: 2021-08-19 authors: Luciano Bestia
In your rust project root directory (where the Cargo.toml is)
first install cargo-auto and generate a new helper project:
bash
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
:
toml
cargo_auto_lib="0.7.*"
Preview the code and observe all the auto_*
functions from cargo_auto_lib
.
Example:
rust
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):
md
1 [comment]: # (auto_cargo_toml_to_md start)
2 [comment]: # (auto_cargo_toml_to_md end)
Run (in your main rust project):
bash
cargo auto release
With a little luck, it included the data of Cargo.toml into the README.md
inside the markers:
All the functions have extensive hep/docs to describe how they work.
It is nice when you use a code editor with IntelliSense like VSCode.
Here is a list of some of them:
auto_cargo_toml_to_md()
- includes data from Cargo.toml to README.md files: version, authors,...auto_delete_old_js_snippets()
- deletes old js snippets when working with wasm-packauto_lines_of_code()
- inserts shield badges with linesofcode into README.rsauto_md_to_doc_comments()
- Finds rs files with markers and include segments from md filesauto_semver_increment_minor()
- increments semver version minor partauto_semver_increment_patch()
- increments semver version patch partauto_version_from_date()
- new version as date is written toCargo.toml and service_worker.jspackage_authors_string_without_emails()
- Cargo.toml package authors as string without emailspackage_description()
- Cargo.toml package repositorypackage_name()
- Cargo.toml package namepackage_repository()
- Cargo.toml package repositorypackage_version()
- Cargo.toml package versionrun_shell_command()
- run one shell commandrun_shell_commands()
- run shell commands from a vector of strings.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!
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 !
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/
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 !