aboutsummaryrefslogtreecommitdiff
path: root/mingling_cli/tmpls
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_cli/tmpls')
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/checklist.toml63
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/rule.toml95
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.gitignore1
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_command/class.toml0
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_completion/class.toml0
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_help/class.toml0
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_outside_type/class.toml0
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_resource/class.toml0
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_setup/class.toml0
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_setup_hook/class.toml0
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_Cargo.toml79
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_build.rs31
-rw-r--r--mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_src/tmpl_main.rs45
13 files changed, 314 insertions, 0 deletions
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/checklist.toml b/mingling_cli/tmpls/mingling_tmpl/0.4/checklist.toml
new file mode 100644
index 0000000..0a5d4a2
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/checklist.toml
@@ -0,0 +1,63 @@
+# --------------------------------------------------------------------------- #
+#
+# Mingling 0.4 Template
+#
+# > Welcome to Mingling.
+# > Before starting your project, please fill out this `checklist` file,
+# > as it will determine the structure of your project.
+#
+# --------------------------------------------------------------------------- #
+
+### 1. Please enter your program name:
+
+program_name = "my-cli"
+
+### 2. Please select the parser used in the project,
+
+# Clap Derive, the most mainstream option.
+# When enabled,
+# Mingling will use the struct implementing clap::Parser as the Entry Type
+# ------------------
+# parser = "clap"
+# ------------------
+
+# Builtin, Mingling's built-in argument parser, lightweight, order-sensitive, suitable for simple parsing
+# ------------------
+# parser = "builtin"
+# ------------------
+
+# Picker, based on `arg-picker`, a lightweight and type-safe argument parser that aligns better with Mingling's paradigm
+# ------------------
+parser = "picker"
+# ------------------
+
+### 3. If you have async requirements, please select an async runtime
+# Hint: You can only enable one of them
+# ------------------
+# tokio = true
+# async_std = true
+# ------------------
+
+### 4. If you need flexible management of your program's exit codes, enable this
+# ------------------
+exit_code = true
+# ------------------
+
+### 5. If your project has completion needs, enable this
+# ------------------
+completion = true
+# ------------------
+
+### 6. If you expect the number of commands to be > 20,
+# enable the compile-time dispatch tree for faster matching
+# ------------------
+# dispatch_tree = true
+# ------------------
+
+### 7. If you want the program to be able to output structured data controlled by flags such as `--json`, enable this
+# ------------------
+# structural_renderer = true
+# ------------------
+
+### Final. All set.
+# Please run `mling proj-init` in this directory to continue creating the project.
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/rule.toml b/mingling_cli/tmpls/mingling_tmpl/0.4/rule.toml
new file mode 100644
index 0000000..0ff6ffb
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/rule.toml
@@ -0,0 +1,95 @@
+[[user.input]]
+name = "program_name"
+
+[[user.toggle]]
+name = "exit_code"
+
+[[user.toggle]]
+name = "tokio"
+
+[[user.toggle]]
+name = "async_std"
+
+[[user.toggle-mutex]]
+mutex = [ "tokio", "async_std" ]
+reason = "You can only select one async runtime"
+
+[[user.toggle]]
+name = "completion"
+
+[[user.toggle]]
+name = "pathf"
+default = true
+
+[[user.toggle]]
+name = "structural_renderer"
+
+[[user.toggle]]
+name = "dispatch_tree"
+
+[[user.toggle]]
+name = "use_parser"
+
+[[user.selection]]
+name = "parser"
+option = [ "clap", "builtin", "picker" ]
+
+[[user.toggle-mutex]]
+mutex = [ "clap", "builtin", "picker" ]
+reason = "You can only select one argument parser"
+
+[[display]]
+name = "ASYNC_STD"
+rule = "async_std"
+
+[[display]]
+name = "TOKIO"
+rule = "tokio"
+
+[[display]]
+name = "ASYNC"
+rule = "tokio || async_std"
+
+[[display]]
+name = "BUILD_TIME"
+rule = "completion || pathf"
+
+[[hide-file]]
+file = "./build.rs"
+rule = "!completion && !pathf"
+
+[[display]]
+name = "PARSER_CLAP"
+rule = "use_parser && parser == clap"
+
+[[display]]
+name = "PARSER_BUILTIN"
+rule = "use_parser && parser == builtin"
+
+[[display]]
+name = "PARSER_PICKER"
+rule = "use_parser && parser == picker"
+
+[[display]]
+name = "COMPLETION"
+rule = "completion"
+
+[[display]]
+name = "STRUCTURAL_RENDERER"
+rule = "structural_renderer"
+
+[[display]]
+name = "EXIT_CODE"
+rule = "exit_code"
+
+[[display]]
+name = "DISPATCH_TREE"
+rule = "dispatch_tree"
+
+[[display]]
+name = "NOT_DISPATCH_TREE"
+rule = "!dispatch_tree"
+
+[[display]]
+name = "PATHF"
+rule = "pathf"
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.gitignore b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_command/class.toml b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_command/class.toml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_command/class.toml
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_completion/class.toml b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_completion/class.toml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_completion/class.toml
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_help/class.toml b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_help/class.toml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_help/class.toml
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_outside_type/class.toml b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_outside_type/class.toml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_outside_type/class.toml
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_resource/class.toml b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_resource/class.toml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_resource/class.toml
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_setup/class.toml b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_setup/class.toml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_setup/class.toml
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_setup_hook/class.toml b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_setup_hook/class.toml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_.mling/tmpl_setup_hook/class.toml
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_Cargo.toml b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_Cargo.toml
new file mode 100644
index 0000000..2345911
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_Cargo.toml
@@ -0,0 +1,79 @@
+[package]
+name = "<<<program_name>>>"
+version = "0.1.0"
+edition = "2024"
+
+[[bin]]
+name = "<<<program_name>>>"
+path = "src/main.rs"
+
+[profile.dev]
+opt-level = 0
+debug = true
+panic = "unwind"
+lto = false
+
+[profile.release]
+opt-level = 3
+# If you need to use exec_panic hook, enable `unwind`
+# panic = "unwind"
+panic = "abort"
+lto = true
+
+[dependencies.mingling]
+version = "0.4"
+features = [
+ "extras",
+??? >>> ASYNC
+ "async",
+??? <<<
+??? >>> PARSER_PICKER
+ "picker",
+??? <<<
+??? >>> PARSER_CLAP
+ "clap",
+??? <<<
+??? >>> PARSER_BUILTIN
+ "parser",
+??? <<<
+??? >>> DISPATCH_TREE
+ "dispatch_tree",
+??? <<<
+??? >>> PATHF
+ "pathf",
+??? <<<
+??? >>> COMPLETION
+ "comp",
+??? <<<
+??? >>> STRUCTURAL_RENDERER
+ "structural_renderer",
+??? <<<
+]
+
+??? >>> BUILD_TIME
+[build-dependencies.mingling]
+version = "0.4"
+features = [
+ "build",
+??? >>> DISPATCH_TREE
+ "dispatch_tree",
+??? <<<
+??? >>> PATHF
+ "pathf",
+??? <<<
+??? >>> COMPLETION
+ "comp",
+??? <<<
+]
+??? <<<
+
+[dependencies]
+??? >>> PARSER_CLAP
+clap = { version = "4", features = [ "derive" ] }
+??? <<<
+??? >>> TOKIO
+tokio = { version = "1", features = [ "full" ] }
+??? <<<
+??? >>> ASYNC_STD
+async-std = "1"
+??? <<<
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_build.rs b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_build.rs
new file mode 100644
index 0000000..e90070c
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_build.rs
@@ -0,0 +1,31 @@
+fn main() {
+??? >>> COMPLETION
+ build_scripts();
+??? <<<
+??? >>> PATHF
+ build_pathf_mapping();
+??? <<<
+}
+??? >>> COMPLETION
+
+/// Generate completion scripts
+fn build_scripts() {
+ // `env!("CARGO_PKG_NAME")` equals the crate name, which matches the binary name.
+ // If your binary name differs from the crate name, specify it explicitly.
+ mingling::build::build_comp_scripts(
+ // Your binary name:
+ env!("CARGO_PKG_NAME"),
+ )
+ .unwrap();
+}
+??? <<<
+??? >>> PATHF
+
+/// Use `pathf` to analyze the workspace's mingling macro calls
+/// and generate type path mappings for them
+fn build_pathf_mapping() {
+ // Build pathf type mapping to ensure that the enabled `pathf` feature
+ // can correctly scan macros in the project
+ mingling::build::analyze_and_build_type_mapping().unwrap();
+}
+??? <<<
diff --git a/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_src/tmpl_main.rs b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_src/tmpl_main.rs
new file mode 100644
index 0000000..02f3cc9
--- /dev/null
+++ b/mingling_cli/tmpls/mingling_tmpl/0.4/tmpl_src/tmpl_main.rs
@@ -0,0 +1,45 @@
+pub(crate) mod commands;
+pub(crate) mod helps;
+pub(crate) mod renderers;
+
+use mingling::macros::buffer;
+use mingling::prelude::*;
+??? >>> EXIT_CODE
+use mingling::setup::ExitCodeSetup;
+??? <<<
+use mingling::setup::picker::BasicProgramSetup;
+
+fn main() {
+ let mut program = ThisProgram::new();
+
+ // Plugins
+ program.with_setup(BasicProgramSetup);
+??? >>> EXIT_CODE
+ program.with_setup(ExitCodeSetup::default());
+??? <<<
+??? >>> COMPLETION
+
+ // Completion Dispatcher
+ program.with_dispatcher(CMDCompletion);
+??? <<<
+??? >>> NOT_DISPATCH_TREE
+
+ // Dispatchers
+ program.with_dispatcher(commands::greet::CMDGreet);
+??? <<<
+
+ program.exec_and_exit();
+}
+
+#[renderer(buffer)]
+fn handle_error_dispatcher_not_found(prev: ErrorDispatcherNotFound) {
+ r_println!("Error: cannot match \"{}\" to any command", prev.join(" "));
+}
+
+#[renderer(buffer)]
+fn handle_error_renderer_not_found(prev: ErrorRendererNotFound) {
+ let type_name = prev.inner;
+ r_println!("Error: renderer not found for \"{}\"", type_name);
+}
+
+gen_program!();