Skip to content

Commit

Permalink
templates from GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
bestia.dev committed May 1, 2024
1 parent 8508143 commit 0bc1405
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 252 deletions.
4 changes: 4 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"line-length": false,
"MD041": false
}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-auto"
version = "2024.501.223"
version = "2024.501.1827"
authors = ["bestia.dev"]
homepage = "https://bestia.dev"
edition = "2021"
Expand Down
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[//]: # (auto_cargo_toml_to_md start)

**Automation tasks coded in Rust language for the workflow of Rust projects**
***version: 2024.501.223 date: 2024-05-01 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)***
***version: 2024.501.1827 date: 2024-05-01 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)***

![maintained](https://img.shields.io/badge/maintained-green)
![ready-for-use](https://img.shields.io/badge/ready_for_use-green)
Expand All @@ -28,11 +28,11 @@
![cargo-auto](https://bestia.dev/webpage_hit_counter/get_svg_image/959103982.svg)

[//]: # (auto_lines_of_code start)
[![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-1949-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
[![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-971-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
[![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-433-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
[![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-1299-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
[![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-742-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
[![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-222-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
[![Lines in examples](https://img.shields.io/badge/Lines_in_examples-0-yellow.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
[![Lines in tests](https://img.shields.io/badge/Lines_in_tests-8881-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
[![Lines in tests](https://img.shields.io/badge/Lines_in_tests-549-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/)

[//]: # (auto_lines_of_code end)

Expand All @@ -58,7 +58,7 @@ cargo auto test
```

We can also add `automation tasks` to an existing Rust project.
Inside your Rust project directory (the one with Cargo.toml) run:
Inside your Rust project directory (the one with `Cargo.toml`) run:

```bash
cargo auto new_auto
Expand Down Expand Up @@ -117,7 +117,7 @@ I composed an opinionated template for a simple Rust WASM project for a browser.
It is easy to run:

```bash
cargo auto new_wasm project_name
cargo auto new_wasm project_name github_owner_or_organization web_server_domain server_username
# then
cd project_name
cargo auto build
Expand All @@ -127,14 +127,12 @@ cargo auto build
## cargo auto new_pwa_wasm

I 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.
The template needs the title, name, long name, and description inside a `pwa.json5` file and the `icon512x512.png` file for the icons.
The 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)
It is easy to run:

```bash
cargo auto new_pwa_wasm
# on first run it will just create the `pwa.json5` and `icon512x512.png` files
# modify these files with data for your new app and then repeat
cargo auto new_pwa_wasm
curl -L https://github.com/automation-tasks-rs/cargo_auto_template_new_pwa_wasm/raw/main/icon512x512.png --output icon512x512.png
cargo auto new_pwa_wasm project_name github_owner_or_organization web_server_domain server_username
# then
cd project_name
cargo auto build
Expand Down
2 changes: 2 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The TODO section is part of the [README.md](https://github.com/automation-tasks-

- new_cli

- templates from GitHub

## Version 2024.422.214 (2024-04-22)

- allow dead code
Expand Down
30 changes: 17 additions & 13 deletions automation_tasks_rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,31 +255,35 @@ fn task_release() {
r#"
{YELLOW}After `cargo auto release`, run the compiled binary, examples and/or tests{RESET}
{YELLOW}1. Check if the template `new_cli` is working. Open a new terminal in VSCode and run:{RESET}
{YELLOW}1. Check if the template `new_cli` is working. Open a second terminal in VSCode and run:{RESET}
{GREEN}cd ~/rustprojects{RESET}
{GREEN}./cargo-auto/target/release/{package_name} new_cli hello_world bestia-dev;{RESET}
{GREEN}code hello_world{RESET}
{YELLOW}In the new VSCODE window terminal, first change in Cargo.toml/repository from "github_owner" to your github username.{RESET}
{YELLOW} Then try the workflow: cargo auto build, cargo auto release, cargo auto doc,... all to the end.{RESET}
{YELLOW}If ok, close the VSCode window. Back in the first terminal check the next template:{RESET}
{YELLOW} Then in the second VSCode window try the workflow: cargo auto build, cargo auto release, cargo auto doc,... all to the end.{RESET}
{YELLOW}If ok, close the second VSCode window. Back in the first VSCode window remove the temporary project:{RESET}
{GREEN}rm -rf hello_world{RESET}
{YELLOW}Kill the second bash terminal from the first VSCode window.{RESET}
{YELLOW}2. Check if the template `new_wasm` is working. Open a new terminal in VSCode and run:{RESET}
{YELLOW}2. Check if the template `new_wasm` is working. Open a second terminal in VSCode and run:{RESET}
{GREEN}cd ~/rustprojects{RESET}
{GREEN}./cargo-auto/target/release/{package_name} new_wasm hello_world bestia-dev bestia.dev luciano_bestia;{RESET}
{GREEN}code hello_world{RESET}
{YELLOW}In the new VSCODE window terminal, first change in Cargo.toml/repository from "github_owner" to your github username.{RESET}
{YELLOW} Then try the workflow: cargo auto build, cargo auto release, cargo auto doc,... all to the end.{RESET}
{YELLOW}If ok, close the VSCode window.{RESET}
{YELLOW} Then in the second VSCode window try the workflow: cargo auto build, cargo auto release, cargo auto doc,... all to the end.{RESET}
{YELLOW}If ok, close the second VSCode window. Back in the first VSCode window remove the temporary project:{RESET}
{GREEN}rm -rf hello_world{RESET}
{YELLOW}Kill the second bash terminal from the first VSCode window.{RESET}
{YELLOW}3. Check if the template `new_pwa_wasm` is working. Open a new terminal in VSCode and run:{RESET}
{YELLOW}3. Check if the template `new_pwa_wasm` is working. Open a second terminal in VSCode and run:{RESET}
{YELLOW}Copy your 'icon512x512.png' into this folder or download and use this default icon.{RESET}
{GREEN}cd ~/rustprojects{RESET}
{GREEN}./cargo-auto/target/release/{package_name} new_pwa_wasm{RESET}
{YELLOW}Follow the instructions{RESET}
{YELLOW}If ok, close the VSCode window.{RESET}
{GREEN}curl -L https://github.com/automation-tasks-rs/cargo_auto_template_new_pwa_wasm/raw/main/icon512x512.png --output icon512x512.png{RESET}
{GREEN}./cargo-auto/target/release/{package_name} new_pwa_wasm hello_world bestia-dev bestia.dev luciano_bestia;{RESET}
{GREEN}code hello_world{RESET}
{YELLOW} Then in the second VSCode window try the workflow: cargo auto build, cargo auto release, cargo auto doc,... all to the end.{RESET}
{YELLOW}If ok, close the second VSCode window. Back in the first VSCode window remove the temporary project:{RESET}
{GREEN}rm icon512x512.png{RESET}
{GREEN}rm -rf hello_world{RESET}
{YELLOW}Kill the second bash terminal from the first VSCode window.{RESET}
{YELLOW}if ok then{RESET}
{GREEN}cargo auto doc{RESET}
Expand Down
22 changes: 10 additions & 12 deletions src/bin/cargo-auto/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! # cargo-auto
//!
//! **Automation tasks coded in Rust language for the workflow of Rust projects**
//! ***version: 2024.501.55 date: 2024-05-01 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)***
//! ***version: 2024.501.1827 date: 2024-05-01 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)***
//!
//! ![maintained](https://img.shields.io/badge/maintained-green)
//! ![ready-for-use](https://img.shields.io/badge/ready_for_use-green)
Expand All @@ -26,11 +26,11 @@
//! [![Newest docs](https://img.shields.io/badge/newest_docs-blue.svg)](https://automation-tasks-rs.github.io/cargo-auto/cargo_auto/index.html)
//! ![cargo-auto](https://bestia.dev/webpage_hit_counter/get_svg_image/959103982.svg)
//!
//! [![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-2565-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-1159-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-615-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-1299-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-742-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-222-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in examples](https://img.shields.io/badge/Lines_in_examples-0-yellow.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in tests](https://img.shields.io/badge/Lines_in_tests-10243-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in tests](https://img.shields.io/badge/Lines_in_tests-549-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//!
//! Hashtags: #maintained #ready-for-use #rustlang #automation #workflow
//! My projects on GitHub are more like a tutorial than a finished product: [bestia-dev tutorials](https://github.com/bestia-dev/tutorials_rust_wasm).
Expand All @@ -54,7 +54,7 @@
//! ```
//!
//! We can also add `automation tasks` to an existing Rust project.
//! Inside your Rust project directory (the one with Cargo.toml) run:
//! Inside your Rust project directory (the one with `Cargo.toml`) run:
//!
//! ```bash
//! cargo auto new_auto
Expand Down Expand Up @@ -113,7 +113,7 @@
//! It is easy to run:
//!
//! ```bash
//! cargo auto new_wasm project_name
//! cargo auto new_wasm project_name github_owner_or_organization web_server_domain server_username
//! # then
//! cd project_name
//! cargo auto build
Expand All @@ -123,14 +123,12 @@
//! ## cargo auto new_pwa_wasm
//!
//! I 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.
//! The template needs the title, name, long name, and description inside a `pwa.json5` file and the `icon512x512.png` file for the icons.
//! The 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)
//! It is easy to run:
//!
//! ```bash
//! cargo auto new_pwa_wasm
//! # on first run it will just create the `pwa.json5` and `icon512x512.png` files
//! # modify these files with data for your new app and then repeat
//! cargo auto new_pwa_wasm
//! curl -L https://github.com/automation-tasks-rs/cargo_auto_template_new_pwa_wasm/raw/main/icon512x512.png --output icon512x512.png
//! cargo auto new_pwa_wasm project_name github_owner_or_organization web_server_domain server_username
//! # then
//! cd project_name
//! cargo auto build
Expand Down
22 changes: 10 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! # cargo-auto
//!
//! **Automation tasks coded in Rust language for the workflow of Rust projects**
//! ***version: 2024.501.55 date: 2024-05-01 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)***
//! ***version: 2024.501.1827 date: 2024-05-01 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/automation-tasks-rs/cargo-auto)***
//!
//! ![maintained](https://img.shields.io/badge/maintained-green)
//! ![ready-for-use](https://img.shields.io/badge/ready_for_use-green)
Expand All @@ -26,11 +26,11 @@
//! [![Newest docs](https://img.shields.io/badge/newest_docs-blue.svg)](https://automation-tasks-rs.github.io/cargo-auto/cargo_auto/index.html)
//! ![cargo-auto](https://bestia.dev/webpage_hit_counter/get_svg_image/959103982.svg)
//!
//! [![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-2565-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-1159-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-615-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-1299-green.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-742-blue.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-222-purple.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in examples](https://img.shields.io/badge/Lines_in_examples-0-yellow.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in tests](https://img.shields.io/badge/Lines_in_tests-10243-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//! [![Lines in tests](https://img.shields.io/badge/Lines_in_tests-549-orange.svg)](https://github.com/automation-tasks-rs/cargo-auto/)
//!
//! Hashtags: #maintained #ready-for-use #rustlang #automation #workflow
//! My projects on GitHub are more like a tutorial than a finished product: [bestia-dev tutorials](https://github.com/bestia-dev/tutorials_rust_wasm).
Expand All @@ -54,7 +54,7 @@
//! ```
//!
//! We can also add `automation tasks` to an existing Rust project.
//! Inside your Rust project directory (the one with Cargo.toml) run:
//! Inside your Rust project directory (the one with `Cargo.toml`) run:
//!
//! ```bash
//! cargo auto new_auto
Expand Down Expand Up @@ -113,7 +113,7 @@
//! It is easy to run:
//!
//! ```bash
//! cargo auto new_wasm project_name
//! cargo auto new_wasm project_name github_owner_or_organization web_server_domain server_username
//! # then
//! cd project_name
//! cargo auto build
Expand All @@ -123,14 +123,12 @@
//! ## cargo auto new_pwa_wasm
//!
//! I 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.
//! The template needs the title, name, long name, and description inside a `pwa.json5` file and the `icon512x512.png` file for the icons.
//! The 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)
//! It is easy to run:
//!
//! ```bash
//! cargo auto new_pwa_wasm
//! # on first run it will just create the `pwa.json5` and `icon512x512.png` files
//! # modify these files with data for your new app and then repeat
//! cargo auto new_pwa_wasm
//! curl -L https://github.com/automation-tasks-rs/cargo_auto_template_new_pwa_wasm/raw/main/icon512x512.png --output icon512x512.png
//! cargo auto new_pwa_wasm project_name github_owner_or_organization web_server_domain server_username
//! # then
//! cd project_name
//! cargo auto build
Expand Down
30 changes: 14 additions & 16 deletions src/outside_of_rust_project_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn print_help_from_cargo_auto() {
{YELLOW}Outside of a Rust project, cargo-auto can create a new Rust project:{RESET}
{GREEN}cargo auto new_cli project_name github_owner{RESET}{YELLOW} - a simple yet complete CLI application, better then `cargo new`{RESET}
{GREEN}cargo auto new_wasm project_name github_owner web_server_domain server_username{RESET}{YELLOW} - a complete wasm application that works inside the browser{RESET}
{GREEN}cargo auto new_pwa_wasm {RESET}{YELLOW} - On first call, it will create the `pwa.json5` and `icon512x512.png` files.{RESET}
{GREEN}cargo auto new_pwa_wasm project_name github_owner web_server_domain server_username{RESET}{YELLOW} - There must already be the `icon512x512.png` file to create the icons.{RESET}
{YELLOW}Modify them with the required data for your pwa project and then repeat the same command.{RESET}
{YELLOW}© 2024 bestia.dev MIT License github.com/automation-tasks-rs/cargo-auto{RESET}
Expand All @@ -58,23 +58,21 @@ fn match_first_argument(task: &str, args: &mut std::env::Args) {
if task == "completion" {
completion();
} else if task == "new_cli" {
// project_name
let arg_2 = args.next();
// github_owner
let arg_3 = args.next();
crate::template_new_cli_mod::new_cli(arg_2, arg_3);
let rust_project_name = args.next();
let github_owner_or_organization = args.next();
crate::template_new_cli_mod::new_cli(rust_project_name, github_owner_or_organization);
} else if task == "new_wasm" {
// project_name
let arg_2 = args.next();
// github_owner
let arg_3 = args.next();
// web server URL
let arg_4 = args.next();
// web server username
let arg_5 = args.next();
crate::template_new_wasm_mod::new_wasm(arg_2, arg_3, arg_4, arg_5);
let rust_project_name = args.next();
let github_owner_or_organization = args.next();
let web_server_domain = args.next();
let server_username = args.next();
crate::template_new_wasm_mod::new_wasm(rust_project_name, github_owner_or_organization, web_server_domain, server_username);
} else if task == "new_pwa_wasm" {
crate::template_new_pwa_wasm_mod::new_pwa_wasm();
let rust_project_name = args.next();
let github_owner_or_organization = args.next();
let web_server_domain = args.next();
let server_username = args.next();
crate::template_new_pwa_wasm_mod::new_pwa_wasm(rust_project_name, github_owner_or_organization, web_server_domain, server_username);
} else {
print_help_from_cargo_auto();
}
Expand Down
4 changes: 2 additions & 2 deletions src/template_new_auto_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ pub fn compile_project_automation_tasks_rs() {
}
}

pub fn copy_to_files(project_name: &str) {
let folder_path = std::path::Path::new(project_name);
pub fn copy_to_files(rust_project_name: &str) {
let folder_path = std::path::Path::new(rust_project_name);
std::fs::create_dir_all(folder_path).unwrap();
for file_item in get_vec_file() {
// create directory if needed
Expand Down
Loading

0 comments on commit 0bc1405

Please sign in to comment.