summaryrefslogtreecommitdiff
path: root/gen
diff options
context:
space:
mode:
Diffstat (limited to 'gen')
-rw-r--r--gen/Cargo.toml13
-rw-r--r--gen/src/constants.rs (renamed from gen/constants.rs)0
-rw-r--r--gen/src/env.rs (renamed from gen/env.rs)0
-rw-r--r--gen/src/gen_commands_file.rs (renamed from gen/gen_commands_file.rs)2
-rw-r--r--gen/src/gen_compile_info.rs (renamed from gen/gen_compile_info.rs)2
-rw-r--r--gen/src/gen_completions_entries.rs (renamed from gen/gen_completions_entries.rs)2
-rw-r--r--gen/src/gen_iscc_script.rs (renamed from gen/gen_iscc_script.rs)2
-rw-r--r--gen/src/gen_mod_files.rs (renamed from gen/gen_mod_files.rs)2
-rw-r--r--gen/src/gen_override_renderer.rs (renamed from gen/gen_override_renderer.rs)23
-rw-r--r--gen/src/gen_renderers_file.rs (renamed from gen/gen_renderers_file.rs)2
-rw-r--r--gen/src/gen_specific_renderer.rs (renamed from gen/gen_specific_renderer.rs)2
-rw-r--r--gen/src/lib.rs11
-rw-r--r--gen/src/resolve_types.rs (renamed from gen/resolve_types.rs)0
13 files changed, 49 insertions, 12 deletions
diff --git a/gen/Cargo.toml b/gen/Cargo.toml
new file mode 100644
index 0000000..186082b
--- /dev/null
+++ b/gen/Cargo.toml
@@ -0,0 +1,13 @@
+[package]
+name = "jv_cli_gen"
+edition = "2024"
+version.workspace = true
+
+[dependencies]
+just_fmt = "0.1.2"
+
+tokio = { version = "1", features = ["rt", "rt-multi-thread"] }
+chrono = "0.4"
+toml = "0.9"
+regex = "1.12"
+just_template = "0.1.3"
diff --git a/gen/constants.rs b/gen/src/constants.rs
index 140743d..140743d 100644
--- a/gen/constants.rs
+++ b/gen/src/constants.rs
diff --git a/gen/env.rs b/gen/src/env.rs
index c45830e..c45830e 100644
--- a/gen/env.rs
+++ b/gen/src/env.rs
diff --git a/gen/gen_commands_file.rs b/gen/src/gen_commands_file.rs
index b68ac0a..c90e356 100644
--- a/gen/gen_commands_file.rs
+++ b/gen/src/gen_commands_file.rs
@@ -3,7 +3,7 @@ use std::path::PathBuf;
use just_fmt::pascal_case;
use just_template::{Template, tmpl, tmpl_param};
-use crate::r#gen::constants::{COMMAND_LIST, COMMAND_LIST_TEMPLATE, COMMANDS_PATH, REGISTRY_TOML};
+use crate::constants::{COMMAND_LIST, COMMAND_LIST_TEMPLATE, COMMANDS_PATH, REGISTRY_TOML};
/// Generate registry file from Registry.toml configuration using just_template
pub async fn generate_commands_file(repo_root: &PathBuf) {
diff --git a/gen/gen_compile_info.rs b/gen/src/gen_compile_info.rs
index 8d68d89..02666ac 100644
--- a/gen/gen_compile_info.rs
+++ b/gen/src/gen_compile_info.rs
@@ -2,7 +2,7 @@ use std::path::PathBuf;
use just_template::{Template, tmpl_param};
-use crate::r#gen::{
+use crate::{
constants::{COMPILE_INFO_RS, COMPILE_INFO_RS_TEMPLATE},
env::{get_git_branch, get_git_commit, get_platform, get_toolchain, get_version},
};
diff --git a/gen/gen_completions_entries.rs b/gen/src/gen_completions_entries.rs
index 0e030e6..7f780b7 100644
--- a/gen/gen_completions_entries.rs
+++ b/gen/src/gen_completions_entries.rs
@@ -1,7 +1,7 @@
use just_template::{Template, tmpl};
use std::path::PathBuf;
-use crate::r#gen::constants::{COMPLETIONS, COMPLETIONS_PATH, COMPLETIONS_TEMPLATE};
+use crate::constants::{COMPLETIONS, COMPLETIONS_PATH, COMPLETIONS_TEMPLATE};
/// Generate completions file from comp directory using just_template
pub async fn generate_completions_file(repo_root: &PathBuf) {
diff --git a/gen/gen_iscc_script.rs b/gen/src/gen_iscc_script.rs
index 23328ab..eabaab3 100644
--- a/gen/gen_iscc_script.rs
+++ b/gen/src/gen_iscc_script.rs
@@ -2,7 +2,7 @@ use std::path::PathBuf;
use just_template::{Template, tmpl_param};
-use crate::r#gen::{
+use crate::{
constants::{SETUP_JV_CLI_ISS, SETUP_JV_CLI_ISS_TEMPLATE},
env::{get_author, get_site, get_version},
};
diff --git a/gen/gen_mod_files.rs b/gen/src/gen_mod_files.rs
index 6e44eac..d0b0800 100644
--- a/gen/gen_mod_files.rs
+++ b/gen/src/gen_mod_files.rs
@@ -1,6 +1,6 @@
use std::path::PathBuf;
-use crate::r#gen::constants::REGISTRY_TOML;
+use crate::constants::REGISTRY_TOML;
/// Generate collect files from directory structure
pub async fn generate_collect_files(repo_root: &PathBuf) {
diff --git a/gen/gen_override_renderer.rs b/gen/src/gen_override_renderer.rs
index 2a8ba37..63b3464 100644
--- a/gen/gen_override_renderer.rs
+++ b/gen/src/gen_override_renderer.rs
@@ -4,7 +4,7 @@ use just_template::{Template, tmpl};
use regex::Regex;
use tokio::fs;
-use crate::r#gen::{
+use crate::{
constants::{
COMMANDS_PATH, OVERRIDE_RENDERER_ENTRY, OVERRIDE_RENDERER_ENTRY_TEMPLATE,
OVERRIDE_RENDERERS, OVERRIDE_RENDERERS_TEMPLATE, REGISTRY_TOML,
@@ -169,6 +169,14 @@ pub fn get_output_types(code: &String) -> Option<Vec<String>> {
output_types.push(type_name.to_string());
}
+ // Find all early_cmd_output! macros
+ let early_cmd_output_re =
+ Regex::new(r"early_cmd_output!\s*\(\s*([^,]+)\s*=>\s*[^)]+\s*\)").ok()?;
+ for cap in early_cmd_output_re.captures_iter(code) {
+ let type_name = cap[1].trim();
+ output_types.push(type_name.to_string());
+ }
+
Some(output_types)
}
@@ -194,10 +202,15 @@ mod tests {
use other::cmds::output::JVCustomOutputOutside;
async fn exec() -> Result<(), CmdExecuteError> {
- cmd_output!(output, JVCustomOutput)
- cmd_output!(output, JVCustomOutput2)
- cmd_output!(output, JVCustomOutputNotExist)
- cmd_output!(output, JVCustomOutputOutside)
+ early_cmd_output!(JVCustomOutput => output)
+ early_cmd_output!(JVCustomOutput2 => {
+ output
+ })
+ cmd_output!(JVCustomOutputNotExist => output)
+ cmd_output!(JVCustomOutputOutside
+ => {
+ output
+ })
}
";
diff --git a/gen/gen_renderers_file.rs b/gen/src/gen_renderers_file.rs
index f16c504..7ac1853 100644
--- a/gen/gen_renderers_file.rs
+++ b/gen/src/gen_renderers_file.rs
@@ -2,7 +2,7 @@ use std::path::PathBuf;
use just_template::{Template, tmpl};
-use crate::r#gen::constants::{
+use crate::constants::{
OVERRIDE_RENDERER_DISPATCHER, OVERRIDE_RENDERER_DISPATCHER_TEMPLATE, REGISTRY_TOML,
};
diff --git a/gen/gen_specific_renderer.rs b/gen/src/gen_specific_renderer.rs
index 95e6900..c68dcec 100644
--- a/gen/gen_specific_renderer.rs
+++ b/gen/src/gen_specific_renderer.rs
@@ -3,7 +3,7 @@ use std::{collections::HashMap, path::PathBuf};
use just_template::{Template, tmpl};
use regex::Regex;
-use crate::r#gen::{
+use crate::{
constants::{RENDERERS_PATH, SPECIFIC_RENDERER_MATCHING, SPECIFIC_RENDERER_MATCHING_TEMPLATE},
resolve_types::resolve_type_paths,
};
diff --git a/gen/src/lib.rs b/gen/src/lib.rs
new file mode 100644
index 0000000..3bd2719
--- /dev/null
+++ b/gen/src/lib.rs
@@ -0,0 +1,11 @@
+pub mod constants;
+pub mod env;
+pub mod gen_commands_file;
+pub mod gen_compile_info;
+pub mod gen_completions_entries;
+pub mod gen_iscc_script;
+pub mod gen_mod_files;
+pub mod gen_override_renderer;
+pub mod gen_renderers_file;
+pub mod gen_specific_renderer;
+pub mod resolve_types;
diff --git a/gen/resolve_types.rs b/gen/src/resolve_types.rs
index 6079abc..6079abc 100644
--- a/gen/resolve_types.rs
+++ b/gen/src/resolve_types.rs