summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock281
-rw-r--r--rola-cli/.gitignore2
-rw-r--r--rola-cli/Cargo.toml14
-rw-r--r--rola-cli/build.rs58
-rw-r--r--rola-cli/src/bin/.gitignore1
-rw-r--r--rola-cli/src/bin/rola.rs16
-rw-r--r--rola-cli/src/lib.rs13
7 files changed, 374 insertions, 11 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c3f4755..312b81d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3,18 +3,128 @@
version = 4
[[package]]
+name = "android_system_properties"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
+
+[[package]]
+name = "bumpalo"
+version = "3.20.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
+
+[[package]]
+name = "cc"
+version = "1.2.64"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dad887fd958be91b5098c0248def011f4523ab786cd411be668777e55063501f"
+dependencies = [
+ "find-msvc-tools",
+ "shlex",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
+
+[[package]]
+name = "chrono"
+version = "0.4.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327"
+dependencies = [
+ "iana-time-zone",
+ "js-sys",
+ "num-traits",
+ "wasm-bindgen",
+ "windows-link",
+]
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+
+[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
+name = "find-msvc-tools"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
+
+[[package]]
+name = "futures-core"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d"
+
+[[package]]
+name = "futures-task"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393"
+
+[[package]]
+name = "futures-util"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "pin-project-lite",
+ "slab",
+]
+
+[[package]]
name = "hashbrown"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
[[package]]
+name = "iana-time-zone"
+version = "0.1.65"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
+dependencies = [
+ "android_system_properties",
+ "core-foundation-sys",
+ "iana-time-zone-haiku",
+ "js-sys",
+ "log",
+ "wasm-bindgen",
+ "windows-core",
+]
+
+[[package]]
+name = "iana-time-zone-haiku"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
+dependencies = [
+ "cc",
+]
+
+[[package]]
name = "indexmap"
version = "2.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -25,12 +135,44 @@ dependencies = [
]
[[package]]
+name = "js-sys"
+version = "0.3.102"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "03d04c30968dffe80775bd4d7fb676131cd04a1fb46d2686dbffbaec2d9dfd31"
+dependencies = [
+ "cfg-if",
+ "futures-util",
+ "wasm-bindgen",
+]
+
+[[package]]
name = "just_fmt"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5454cda0d57db59778608d7a47bff5b16c6705598265869fb052b657f66cf05e"
[[package]]
+name = "just_template"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db3edb658c34b10b69c4b3b58f7ba989cd09c82c0621dee1eef51843c2327225"
+dependencies = [
+ "just_fmt",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.186"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
+
+[[package]]
+name = "log"
+version = "0.4.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a"
+
+[[package]]
name = "memchr"
version = "2.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -52,6 +194,7 @@ version = "0.2.0"
source = "git+https://github.com/mingling-rs/mingling.git?rev=002f3fd390f64b1d7632f8530a0db81d45edf6c2#002f3fd390f64b1d7632f8530a0db81d45edf6c2"
dependencies = [
"just_fmt",
+ "just_template",
]
[[package]]
@@ -66,6 +209,21 @@ dependencies = [
]
[[package]]
+name = "num-traits"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+
+[[package]]
name = "pin-project-lite"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -105,6 +263,7 @@ dependencies = [
name = "rola-cli"
version = "0.1.0"
dependencies = [
+ "chrono",
"mingling",
"rorolala",
"shakehand",
@@ -129,6 +288,12 @@ dependencies = [
]
[[package]]
+name = "rustversion"
+version = "1.0.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
+
+[[package]]
name = "serde"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -204,12 +369,24 @@ dependencies = [
]
[[package]]
+name = "shlex"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+
+[[package]]
name = "size"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6709c7b6754dca1311b3c73e79fcce40dd414c782c66d88e8823030093b02b"
[[package]]
+name = "slab"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
+
+[[package]]
name = "space-macros"
version = "0.1.0"
dependencies = [
@@ -329,6 +506,110 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
+name = "wasm-bindgen"
+version = "0.2.125"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ddb3f79143bced6de84270411622a2699cee572fc0875aeaf1e7867cf9fca1a"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "rustversion",
+ "wasm-bindgen-macro",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.125"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4e21a184b13fb19e157296e2c46056aec9092264fab83e4ba59e68c61b323c3d"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.125"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fecefd9c35bd935a20fc3fc344b5f29138961e4f47fb03297d88f2587afb5ebd"
+dependencies = [
+ "bumpalo",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.125"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23939e44bb9a5d7576fa2b563dc2e136628f1224e88a8deed09e04858b77871f"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "windows-core"
+version = "0.62.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
+dependencies = [
+ "windows-implement",
+ "windows-interface",
+ "windows-link",
+ "windows-result",
+ "windows-strings",
+]
+
+[[package]]
+name = "windows-implement"
+version = "0.60.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "windows-interface"
+version = "0.59.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-result"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-strings"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
name = "winnow"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/rola-cli/.gitignore b/rola-cli/.gitignore
new file mode 100644
index 0000000..b0b27d9
--- /dev/null
+++ b/rola-cli/.gitignore
@@ -0,0 +1,2 @@
+src/bin/debug.rs
+version.txt
diff --git a/rola-cli/Cargo.toml b/rola-cli/Cargo.toml
index a04a403..6b45c5a 100644
--- a/rola-cli/Cargo.toml
+++ b/rola-cli/Cargo.toml
@@ -23,5 +23,17 @@ rev = "002f3fd390f64b1d7632f8530a0db81d45edf6c2"
features = [
"parser",
"extra_macros",
- "dispatch_tree"
+ "dispatch_tree",
+ "comp"
]
+
+[build-dependencies.mingling]
+git = "https://github.com/mingling-rs/mingling.git"
+rev = "002f3fd390f64b1d7632f8530a0db81d45edf6c2"
+features = [
+ "builds",
+ "comp"
+]
+
+[build-dependencies]
+chrono = "0.4.45"
diff --git a/rola-cli/build.rs b/rola-cli/build.rs
new file mode 100644
index 0000000..a409a17
--- /dev/null
+++ b/rola-cli/build.rs
@@ -0,0 +1,58 @@
+use std::path::Path;
+use std::process::Command;
+
+use mingling::build::build_comp_scripts;
+
+fn main() {
+ build_version_info();
+ build_completion();
+}
+
+fn build_version_info() {
+ // Read version from CARGO_PKG_VERSION (inherited from workspace Cargo.toml)
+ let version = env!("CARGO_PKG_VERSION");
+
+ // Get git commit hash (first 9 characters)
+ let commit_hash = Command::new("git")
+ .args(["rev-parse", "--short=9", "HEAD"])
+ .output()
+ .ok()
+ .and_then(|output| {
+ if output.status.success() {
+ String::from_utf8(output.stdout).ok()
+ } else {
+ None
+ }
+ })
+ .map(|s| s.trim().to_string())
+ .unwrap_or_else(|| "unknown".to_string());
+
+ // Get date from git commit, fallback to current date
+ let date = Command::new("git")
+ .args(["log", "-1", "--format=%ad", "--date=format:%Y-%m-%d"])
+ .output()
+ .ok()
+ .and_then(|output| {
+ if output.status.success() {
+ String::from_utf8(output.stdout).ok()
+ } else {
+ None
+ }
+ })
+ .map(|s| s.trim().to_string())
+ .unwrap_or_else(|| chrono::Local::now().format("%Y-%m-%d").to_string());
+
+ let version_string = format!("rola {version} ({commit_hash} {date})");
+
+ let out_dir = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("version.txt");
+
+ std::fs::write(&out_dir, version_string).expect("failed to write version.txt");
+
+ println!("cargo::rerun-if-changed=../Cargo.toml");
+ println!("cargo::rerun-if-changed=../Cargo.lock");
+ println!("cargo::rerun-if-changed=.git/HEAD");
+}
+
+fn build_completion() {
+ build_comp_scripts("rola").unwrap();
+}
diff --git a/rola-cli/src/bin/.gitignore b/rola-cli/src/bin/.gitignore
deleted file mode 100644
index 6754721..0000000
--- a/rola-cli/src/bin/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-debug.rs
diff --git a/rola-cli/src/bin/rola.rs b/rola-cli/src/bin/rola.rs
index 1ebc3ae..0cfe675 100644
--- a/rola-cli/src/bin/rola.rs
+++ b/rola-cli/src/bin/rola.rs
@@ -3,19 +3,13 @@ use std::{env::current_dir, process::exit};
use mingling::{
Program,
macros::program_setup,
- setup::{BasicProgramSetup, ExitCodeSetup, QuietFlagSetup},
+ setup::{ExitCodeSetup, HelpFlagSetup, QuietFlagSetup},
};
use rola_cli::{ThisProgram, locale, res::current_dir::ResCurrentDir};
fn main() {
let mut program = ThisProgram::new();
- program.global_flag(["-v", "--version"], |_| {
- let help = locale::helps::Basic::help().trim();
- eprintln!("{}", help);
- exit(0)
- });
-
// Language
locale::set_lang(
program
@@ -23,14 +17,20 @@ fn main() {
.unwrap_or(locale::current_locales()),
);
+ // Version
+ program.global_flag(["-v", "--version"], |_| {
+ eprintln!("{}", include_str!("../../version.txt"));
+ exit(0)
+ });
+
// Resources
program.with_resource(ResCurrentDir {
cwd: current_dir().unwrap(),
});
// Setup
+ program.with_setup(HelpFlagSetup::new(["-h", "--help"]));
program.with_setup(StandardOutputSetup);
- program.with_setup(BasicProgramSetup);
program.with_setup(ExitCodeSetup::default());
// Execute
diff --git a/rola-cli/src/lib.rs b/rola-cli/src/lib.rs
index f81c34e..54ff09a 100644
--- a/rola-cli/src/lib.rs
+++ b/rola-cli/src/lib.rs
@@ -1,4 +1,6 @@
-use mingling::macros::gen_program;
+use std::process::exit;
+
+use mingling::macros::{gen_program, help};
pub mod res;
pub mod tokio_wrapper;
@@ -9,6 +11,15 @@ use bucket_mgr::*;
mod error;
use error::*;
+#[help]
+fn handle_error_dispatch_not_found(_err: ErrorDispatcherNotFound) {
+ let help = locale::helps::Basic::help().trim();
+
+ // Print directly to stderr and exit with code 0
+ eprintln!("{}", help);
+ exit(0)
+}
+
gen_program!();
pub mod locale {