From 506df24aaef42d6aaa30dee8187ef11f92809432 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 12 Jan 2025 08:52:28 +0800 Subject: [PATCH] feat: v0.4.0, change js to ts --- Cargo.lock | 2 +- Cargo.toml | 4 ++-- justfile | 18 +++++++++--------- src/help_js.rs | 19 ------------------- src/help_ts.rs | 19 +++++++++++++++++++ src/install.rs | 4 ++-- src/list.rs | 4 ++-- src/main.rs | 18 +++++++++--------- ...{script.template.js => script.template.ts} | 0 src/util.rs | 8 ++++---- 10 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 src/help_js.rs create mode 100644 src/help_ts.rs rename src/{script.template.js => script.template.ts} (100%) diff --git a/Cargo.lock b/Cargo.lock index 7fa38db..2b51ef4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -864,7 +864,7 @@ dependencies = [ [[package]] name = "runrs" -version = "0.3.0" +version = "0.4.0" dependencies = [ "argh", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index 96fa6a8..e2005f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runrs" -version = "0.3.0" +version = "0.4.0" edition = "2018" license = "MIT/Apache-2.0" description = "A Tool for Run Rust Scripts" @@ -12,7 +12,7 @@ readme = "README.md" default = ["switch-rust-lang"] switch-rust-lang = [] switch-go-lang = [] -switch-js-lang = [] +switch-ts-lang = [] switch-dart-lang = [] [dependencies] diff --git a/justfile b/justfile index e931141..0592c23 100644 --- a/justfile +++ b/justfile @@ -10,8 +10,8 @@ run-rust *args: run-go *args: cargo run --no-default-features --features switch-go-lang -- {{args}} -run-js *args: - cargo run --no-default-features --features switch-js-lang -- {{args}} +run-ts *args: + cargo run --no-default-features --features switch-ts-lang -- {{args}} run-dart *args: cargo run --no-default-features --features switch-dart-lang -- {{args}} @@ -22,8 +22,8 @@ build-run-rust: build-run-go: cargo build --release --no-default-features --features switch-go-lang -build-run-js: - cargo build --release --no-default-features --features switch-js-lang +build-run-ts: + cargo build --release --no-default-features --features switch-ts-lang build-run-dart: cargo build --release --no-default-features --features switch-dart-lang @@ -32,9 +32,9 @@ install-run-go: cargo build --release --no-default-features --features switch-go-lang cp target/release/runrs ~/bin/rungo -install-run-js: - cargo build --release --no-default-features --features switch-js-lang - cp target/release/runrs ~/bin/runjss +install-run-ts: + cargo build --release --no-default-features --features switch-ts-lang + cp target/release/runrs ~/bin/runts install-run-dart: cargo build --release --no-default-features --features switch-dart-lang @@ -43,11 +43,11 @@ install-run-dart: build-all: @just build-run-rust @just build-run-go - @just build-run-js + @just build-run-ts @just build-run-dart install-all: @just install @just install-run-go - @just install-run-js + @just install-run-ts @just install-run-dart diff --git a/src/help_js.rs b/src/help_js.rs deleted file mode 100644 index 058460e..0000000 --- a/src/help_js.rs +++ /dev/null @@ -1,19 +0,0 @@ -pub fn print_help() { - println!(r##"runjs v{} - A Tool for Run JS Scripts - -Show help: -$ runjs -h|--help - -Show template: -$ runjs -t|--template [--output script.js] - -Show scriptions: -$ runjs -l|--list - -Install script: -$ runjs -i|--install - -"##, - env!("CARGO_PKG_VERSION") - ); -} \ No newline at end of file diff --git a/src/help_ts.rs b/src/help_ts.rs new file mode 100644 index 0000000..9154898 --- /dev/null +++ b/src/help_ts.rs @@ -0,0 +1,19 @@ +pub fn print_help() { + println!(r##"runts v{} - A Tool for Run TS Scripts + +Show help: +$ runts -h|--help + +Show template: +$ runts -t|--template [--output script.ts] + +Show scriptions: +$ runts -l|--list + +Install script: +$ runts -i|--install + +"##, + env!("CARGO_PKG_VERSION") + ); +} \ No newline at end of file diff --git a/src/install.rs b/src/install.rs index ec0f1be..16af99f 100644 --- a/src/install.rs +++ b/src/install.rs @@ -11,9 +11,9 @@ const SCRIPT_PATTERN: &str = #[cfg(feature = "switch-go-lang")] const SCRIPT_PATTERN: &str = "https://git.hatter.ink/hatter/go-scripts/raw/branch/main/$NAME/main.go"; -#[cfg(feature = "switch-js-lang")] +#[cfg(feature = "switch-ts-lang")] const SCRIPT_PATTERN: &str = - "https://git.hatter.ink/hatter/js-scripts/raw/branch/main/$NAME/main.js"; + "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/$NAME/main.ts"; #[cfg(feature = "switch-dart-lang")] const SCRIPT_PATTERN: &str = "https://git.hatter.ink/hatter/dart-scripts/raw/branch/main/$NAME/main.dart"; diff --git a/src/list.rs b/src/list.rs index f2b79db..9ef5e87 100644 --- a/src/list.rs +++ b/src/list.rs @@ -9,8 +9,8 @@ use crate::util::{SCRIPT_DOT_EXT, SCRIPT_HYPHEN_EXT}; const FILE_META: &str = "https://git.hatter.ink/rust-scripts/scriptbase/raw/branch/main/script-meta.json"; #[cfg(feature = "switch-go-lang")] const FILE_META: &str = "https://git.hatter.ink/hatter/go-scripts/raw/branch/main/script-meta.json"; -#[cfg(feature = "switch-js-lang")] -const FILE_META: &str = "https://git.hatter.ink/hatter/js-scripts/raw/branch/main/script-meta.json"; +#[cfg(feature = "switch-ts-lang")] +const FILE_META: &str = "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/script-meta.json"; #[cfg(feature = "switch-dart-lang")] const FILE_META: &str = "https://git.hatter.ink/hatter/dart-scripts/raw/branch/main/script-meta.json"; diff --git a/src/main.rs b/src/main.rs index aa44fed..22d93f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,8 +16,8 @@ use crate::util::{ mod help_dart; #[cfg(feature = "switch-go-lang")] mod help_go; -#[cfg(feature = "switch-js-lang")] -mod help_js; +#[cfg(feature = "switch-ts-lang")] +mod help_ts; #[cfg(feature = "switch-rust-lang")] mod help_rs; mod install; @@ -28,8 +28,8 @@ mod util; const CMD_NAME: &str = "runrs"; #[cfg(feature = "switch-go-lang")] const CMD_NAME: &str = "rungo"; -#[cfg(feature = "switch-js-lang")] -const CMD_NAME: &str = "runjs"; +#[cfg(feature = "switch-ts-lang")] +const CMD_NAME: &str = "runts"; #[cfg(feature = "switch-dart-lang")] const CMD_NAME: &str = "rundart"; @@ -100,7 +100,7 @@ fn main() { #[cfg(any( feature = "switch-go-lang", - feature = "switch-js-lang", + feature = "switch-ts-lang", feature = "switch-dart-lang" ))] if true { @@ -134,8 +134,8 @@ fn print_help() { help_rs::print_help(); #[cfg(feature = "switch-go-lang")] help_go::print_help(); - #[cfg(feature = "switch-js-lang")] - help_js::print_help(); + #[cfg(feature = "switch-ts-lang")] + help_ts::print_help(); #[cfg(feature = "switch-dart-lang")] help_dart::print_help(); } @@ -145,8 +145,8 @@ fn print_template(output: &Option) { let script = include_str!("script.template.rs"); #[cfg(feature = "switch-go-lang")] let script = include_str!("script.template.go"); - #[cfg(feature = "switch-js-lang")] - let script = include_str!("script.template.js"); + #[cfg(feature = "switch-ts-lang")] + let script = include_str!("script.template.ts"); #[cfg(feature = "switch-dart-lang")] let script = include_str!("script.template.dart"); match output { diff --git a/src/script.template.js b/src/script.template.ts similarity index 100% rename from src/script.template.js rename to src/script.template.ts diff --git a/src/util.rs b/src/util.rs index 9350209..92993bc 100644 --- a/src/util.rs +++ b/src/util.rs @@ -9,8 +9,8 @@ use std::{env, fs, process}; pub const SCRIPT_HYPHEN_EXT: &str = "-rs"; #[cfg(feature = "switch-go-lang")] pub const SCRIPT_HYPHEN_EXT: &str = "-go"; -#[cfg(feature = "switch-js-lang")] -pub const SCRIPT_HYPHEN_EXT: &str = "-js"; +#[cfg(feature = "switch-ts-lang")] +pub const SCRIPT_HYPHEN_EXT: &str = "-ts"; #[cfg(feature = "switch-dart-lang")] pub const SCRIPT_HYPHEN_EXT: &str = "-dart"; @@ -18,8 +18,8 @@ pub const SCRIPT_HYPHEN_EXT: &str = "-dart"; pub const SCRIPT_DOT_EXT: &str = ".rs"; #[cfg(feature = "switch-go-lang")] pub const SCRIPT_DOT_EXT: &str = ".go"; -#[cfg(feature = "switch-js-lang")] -pub const SCRIPT_DOT_EXT: &str = ".js"; +#[cfg(feature = "switch-ts-lang")] +pub const SCRIPT_DOT_EXT: &str = ".ts"; #[cfg(feature = "switch-dart-lang")] pub const SCRIPT_DOT_EXT: &str = ".dart";