{"id":15032594,"url":"https://github.com/automation-tasks-rs/cargo-auto","last_synced_at":"2025-04-09T21:24:09.092Z","repository":{"id":57532578,"uuid":"395637909","full_name":"automation-tasks-rs/cargo-auto","owner":"automation-tasks-rs","description":"Automation tasks coded in Rust language for the workflow of Rust projects","archived":false,"fork":false,"pushed_at":"2025-03-29T15:46:44.000Z","size":9011,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T16:30:03.094Z","etag":null,"topics":["automation","maintained","ready-for-use","rustlang","workflow"],"latest_commit_sha":null,"homepage":"https://automation-tasks-rs.github.io/cargo-auto/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/automation-tasks-rs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-13T11:59:48.000Z","updated_at":"2025-03-29T15:46:48.000Z","dependencies_parsed_at":"2024-02-18T06:27:39.836Z","dependency_job_id":"4c764e51-e5f0-4f63-8480-e8d407b4ccfc","html_url":"https://github.com/automation-tasks-rs/cargo-auto","commit_stats":{"total_commits":113,"total_committers":3,"mean_commits":"37.666666666666664","dds":0.5309734513274336,"last_synced_commit":"0b210e16681349f63ea57bef718e60e44358139a"},"previous_names":["automation-tasks-rs/cargo-auto"],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/automation-tasks-rs%2Fcargo-auto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/automation-tasks-rs%2Fcargo-auto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/automation-tasks-rs%2Fcargo-auto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/automation-tasks-rs%2Fcargo-auto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/automation-tasks-rs","download_url":"https://codeload.github.com/automation-tasks-rs/cargo-auto/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248113246,"owners_count":21049811,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","maintained","ready-for-use","rustlang","workflow"],"created_at":"2024-09-24T20:18:48.762Z","updated_at":"2025-04-09T21:24:09.086Z","avatar_url":"https://github.com/automation-tasks-rs.png","language":"Rust","funding_links":["https://paypal.me/LucianoBestia"],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable MD041 --\u003e\n[//]: # (auto_md_to_doc_comments segment start A)\n\n# cargo-auto  \n\n[//]: # (auto_cargo_toml_to_md start)\n\n**Automation tasks coded in Rust language for the workflow of Rust projects**  \n***version: 2025.401.1812 date: 2025-04-02 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)***\n\n ![maintained](https://img.shields.io/badge/maintained-green)\n ![ready-for-use](https://img.shields.io/badge/ready_for_use-green)\n ![rustlang](https://img.shields.io/badge/rustlang-orange)\n ![automation](https://img.shields.io/badge/automation-orange)\n ![workflow](https://img.shields.io/badge/workflow-orange)\n\n[//]: # (auto_cargo_toml_to_md end)\n\n ![logo](https://raw.githubusercontent.com/automation-tasks-rs/cargo-auto/main/images/logo/logo_cargo_auto.svg)\n cargo-auto is part of the [automation_tasks_rs](https://github.com/automation-tasks-rs) project\n\n [![crates.io](https://img.shields.io/crates/v/cargo-auto.svg)](https://crates.io/crates/cargo-auto)\n [![Documentation](https://docs.rs/cargo-auto/badge.svg)](https://docs.rs/cargo-auto/)\n [![crev reviews](https://web.crev.dev/rust-reviews/badge/crev_count/cargo-auto.svg)](https://web.crev.dev/rust-reviews/crate/cargo-auto/)\n [![Lib.rs](https://img.shields.io/badge/Lib.rs-rust-orange.svg)](https://lib.rs/crates/cargo-auto/)  \n [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/blob/master/LICENSE)\n [![Rust](https://github.com/automation-tasks-rs/cargo-auto/workflows/rust_fmt_auto_build_test/badge.svg)](https://github.com/automation-tasks-rs/cargo-auto/)\n [![Newest docs](https://img.shields.io/badge/newest_docs-blue.svg)](https://automation-tasks-rs.github.io/cargo-auto/cargo_auto/index.html)\n ![cargo-auto](https://bestia.dev/webpage_hit_counter/get_svg_image/959103982.svg)\n\n[//]: # (auto_lines_of_code start)\n[![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-849-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/)\n[![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-596-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/)\n[![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-110-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/)\n[![Lines in examples](https://img.shields.io/badge/Lines_in_examples-0-yellow.svg)](https://github.com/automation-tasks-rs/cargo-auto/)\n[![Lines in tests](https://img.shields.io/badge/Lines_in_tests-0-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/)\n\n[//]: # (auto_lines_of_code end)\n\nHashtags: #maintained #ready-for-use #rustlang #automation #workflow  \nMy projects on GitHub are more like a tutorial than a finished product: [bestia-dev tutorials](https://github.com/bestia-dev/tutorials_rust_wasm).  \nI recommend using the [CRUSTDE - Containerized Rust Development Environment](https://github.com/CRUSTDE-ContainerizedRustDevEnvrustde_cnt_img_pod) to write Rust projects on Linux, isolated from your system.  \n\n## Try it\n\nFirst, we will use `cargo-auto` to create a new empty CLI Rust project similar to `cargo new`, but with a more complete project structure.  \n\n ```bash\ncargo install cargo-auto\ncargo auto new_cli my_hello_project\ncd my_hello_project\ncargo auto\n# it lists all the prepared automation tasks\n# try a few\ncargo auto build\ncargo auto release\ncargo auto doc\ncargo auto test\n```\n\nWe can also add `automation tasks` to an existing Rust project.\nInside your Rust project directory (the one with `Cargo.toml`) run:  \n\n```bash\ncargo auto new_auto_for_cli\ncargo auto\n# it lists all the prepared automation tasks\n# try to build\ncargo auto build\n```\n\nCongratulations! You are already using `cargo-auto`. Simple as that.  \nNow you can modify the tasks to your needs. It is all Rust language.  \n\n## Motivation\n\nCargo is a great tool for building Rust projects. It has all the basics: `cargo build`, `cargo build --release`, `cargo fmt`, `cargo test`, `cargo doc`,...  \nBut sometimes we need to do more things like copying some files, publishing to FTP, or entering long commands. These repetitive tasks must be automated.  \nTask automation makes work easier and faster, and simplifies the workflow while improving the consistency and accuracy of workflows.  \nThis is also sometimes referred to as \"workflow automation.\"  \nThere are many different build systems and task runners there: `make`, `cmake`, `shell scripts`, `cargo-xtask`, `cargo-make`, `cargo-task`, `cargo-script`, `cargo-run-script`, `runner`, `python scripts`, `powershell scripts`, `cmd prompt scripts`, ...  \nSadly there is no standard in the Rust community for now.  \nI want something similar to [build.rs](https://doc.rust-lang.org/cargo/reference/build-scripts.html), so I can write my \"tasks\" in pure Rust I don't want to learn another meta language with weird syntax and difficulty to debug. So I will make something really simple, easy, rusty, and extensible.  \n\n## cargo auto subcommand\n\nThe command `cargo install cargo-auto` will add a new subcommand to cargo:\n\n```bash\ncargo auto\n```\n\nThis binary is super simple. It has only 1 trivial dependency: `lazy_static`.  \nThe binary only reads the CLI arguments and runs the `automation_tasks_rs` binary with them. If needed it will compile `automation_tasks_rs` first.  \nThe code-flow of the source code of `cargo-auto` is simple, fully commented, and straightforward to audit.  \nThe source code is on [GitHub](https://github.com/automation-tasks-rs/cargo-auto) with MIT open-source licensing.  \n\n## bash auto-completion\n\nWith the help of the crate [dev_bestia_cargo_completion](https://crates.io/crates/dev_bestia_cargo_completion), the commands `cargo` and `cargo auto` get bash auto-completion. Try it!  \n\n## cargo auto new_cli\n\nI like very much that Rust has the command `cargo new project_name`. It creates a super simple Rust Hello project that can be built and run immediately. But this example is too simple. It lacks the basic file structures of a serious CLI program.  \nI composed an opinionated template for a Rust CLI project. It is easy to run:\n\n```bash\ncargo auto new_cli project_name\n# then\ncd project_name\ncargo auto build\n# then follow detailed instructions\n```\n\n## cargo auto new_wasm\n\nI composed an opinionated template for a simple Rust WASM project for a browser. It is very similar to the new_cli template but for WASM.  \nIt is easy to run:\n\n```bash\ncargo auto new_wasm project_name github_owner_or_organization web_server_domain server_username\n# then\ncd project_name\ncargo auto build\n# then follow detailed instructions\n```\n\n## cargo auto new_pwa_wasm\n\nI composed an opinionated template for a simple Rust PWA-WASM project for a browser. It is very similar to the new_cli template but for WASM. It adds the PWA standard functionality to work as an offline app.  \nThe template needs the `icon512x512.png` file for the icons. You can use the default icon if you don't have your own. ![icon512x512.png](https://github.com/automation-tasks-rs/cargo_auto_template_new_pwa_wasm/raw/main/icon512x512.png)  \nIt is easy to run:\n\n```bash\ncurl -L https://github.com/automation-tasks-rs/cargo_auto_template_new_pwa_wasm/raw/main/icon512x512.png --output icon512x512.png\ncargo auto new_pwa_wasm project_name github_owner_or_organization web_server_domain server_username\n# then\ncd project_name\ncargo auto build\n# then follow detailed instructions\n```\n\n## scripting with rust\n\nRust is a compiled language. It is not really a scripting or interpreted language. But the compilation of small projects is really fast and can be ignored. Subsequent calls will use the already-built binary so the speed will be even faster.  \nThis tool `cargo-auto` is meant for Rust projects, so it means that all the Rust infrastructure is already in place.  \n\n## automation_tasks_rs Rust sub-project\n\nThe command `cargo auto new_auto_for_cli` will create a new Rust sub-project`automation_tasks_rs` inside your `Rust project`. It should not interfere with the main Rust project. This directory will be added to git commits and pushed to remote repositories as part of the main project. It has its own `.gitignore` to avoid committing to its target directory.  \nThe `automation_tasks_rs` helper project contains user-defined tasks in Rust code. Your tasks. This helper project should be opened in a new editor starting from the `automation_tasks_rs` directory. It does not share dependencies with the main project. It is completely separate and independent.  \nYou can edit it and add your dependencies and Rust code. No limits. Freedom of expression.  \nThis is now your code, your tasks, and your helper Rust project!  \nBecause only you know what you want to automate and how to do it.  \nNever write secrets, passwords, passphrases, or tokens inside your Rust code. Because then it is pushed to GitHub and the whole world can read it in the next second!\nBasic example (most of the useful functions are already there):  \n\n```rust ignore\n/// match arguments and call tasks functions\nfn match_arguments_and_call_tasks(mut args: std::env::Args){\n    // the first argument is the user defined task: (no argument for help), build, release,...\n    let arg_1 = args.next();\n    match arg_1 {\n        None =\u003e print_help(),\n        Some(task) =\u003e {            \n            println!(\"Running auto task: {}\", \u0026task);\n            if \u0026task == \"build\"{\n                task_build();\n            } else if \u0026task == \"release\" {\n                task_release();\n            } else if \u0026task == \"doc\" {\n                task_doc();\n            } else {\n                println!(\"Task {} is unknown.\", \u0026task);\n                print_help();\n            }\n        }\n    }\n}\n\n/// write a comprehensible help for user defined tasks\nfn print_help() {\n    println!(r#\"\n    User defined tasks in automation_tasks_rs:\ncargo auto build - builds the crate in debug mode\ncargo auto release - builds the crate in release mode\ncargo auto docs - builds the docs\n\"#);\n}\n\n// region: tasks\n\n/// cargo build\nfn task_build() {\n    run_shell_command(\"cargo fmt\");\n    run_shell_command(\"cargo build\");\n}\n\n/// cargo build --release\nfn task_release() {\n    run_shell_command(\"cargo fmt\");\n    run_shell_command(\"cargo build --release\");\n}\n\n/// cargo doc, then copies to /docs/ folder, because this is a github standard folder\nfn task_doc() {\n    run_shell_command(\"cargo doc --no-deps --document-private-items\");\n    // copy target/doc into docs/ because it is github standard\n    run_shell_command(\"rsync -a --info=progress2 --delete-after target/doc/ docs/\");\n    // Create simple index.html file in docs directory\n    run_shell_command(\u0026format!(\n        \"printf \\\"\u003cmeta http-equiv=\\\\\\\"refresh\\\\\\\" content=\\\\\\\"0; url={}/index.html\\\\\\\" /\u003e\\\\n\\\" \u003e docs/index.html\",\n        cargo_toml.package_name().replace(\"-\",\"_\")\n    ));\n    run_shell_command(\"cargo fmt\");\n}\n\n// endregion: tasks\n\n```\n\n## more complex tasks\n\nYou can write more complex tasks in Rust language.  \nFor example in this project I use automation to create GitHub Releases: \u003chttps://github.com/automation-tasks-rs/dropbox_backup_to_external_disk\u003e  \nHere is a pretty complex workspace with more sub-projects:  \n\u003chttps://github.com/automation-tasks-rs/cargo_crev_reviews_workspace\u003e  \nThere is no end to your imagination. If you write something that looks like it can help other developers, please share it with me and I will add it here.\n\n## Development details\n\nRead the development details in a separate md file:  \n[DEVELOPMENT.md](https://github.com/automation-tasks-rs/cargo-auto/blob/main/DEVELOPMENT.md)\n\n## Releases changelog\n\nRead the changelog in a separate md file:  \n[RELEASES.md](https://github.com/automation-tasks-rs/cargo-auto/blob/main/RELEASES.md)\n\n## TODO\n\nNothing big in the near future.\n\n## Open-source and free as a beer\n\nMy open-source projects are free as a beer (MIT license).  \nI just love programming.  \nBut I need also to drink. If you find my projects and tutorials helpful, please buy me a beer by donating to my [PayPal](https://paypal.me/LucianoBestia).  \nYou know the price of a beer in your local bar ;-)  \nSo I can drink a free beer for your health :-)  \n[Na zdravje!](https://translate.google.com/?hl=en\u0026sl=sl\u0026tl=en\u0026text=Na%20zdravje\u0026op=translate) [Alla salute!](https://dictionary.cambridge.org/dictionary/italian-english/alla-salute) [Prost!](https://dictionary.cambridge.org/dictionary/german-english/prost) [Nazdravlje!](https://matadornetwork.com/nights/how-to-say-cheers-in-50-languages/) 🍻\n\n[//bestia.dev](https://bestia.dev)  \n[//github.com/automation-tasks-rs](https://github.com/automation-tasks-rs)  \n[//bestiadev.substack.com](https://bestiadev.substack.com)  \n[//youtube.com/@bestia-dev-tutorials](https://youtube.com/@bestia-dev-tutorials)  \n\n[//]: # (auto_md_to_doc_comments segment end A)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautomation-tasks-rs%2Fcargo-auto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fautomation-tasks-rs%2Fcargo-auto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautomation-tasks-rs%2Fcargo-auto/lists"}