From cde7be4e67aea4378fbac8462ba8fff48b73ea1e Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 9 Aug 2026 01:14:19 +0800 Subject: feat(tscn-to-bsn): add global help fallback support Add a fallback module providing a help command that displays usage information for the tool. --- tools/tscn-to-bsn/src/bin/tscn2bsn.rs | 2 ++ tools/tscn-to-bsn/src/fallback.rs | 13 +++++++++++++ tools/tscn-to-bsn/src/helps/help.txt | 15 +++++++++++++++ tools/tscn-to-bsn/src/lib.rs | 1 + 4 files changed, 31 insertions(+) create mode 100644 tools/tscn-to-bsn/src/fallback.rs create mode 100644 tools/tscn-to-bsn/src/helps/help.txt diff --git a/tools/tscn-to-bsn/src/bin/tscn2bsn.rs b/tools/tscn-to-bsn/src/bin/tscn2bsn.rs index 4ac1f5a..84d6444 100644 --- a/tools/tscn-to-bsn/src/bin/tscn2bsn.rs +++ b/tools/tscn-to-bsn/src/bin/tscn2bsn.rs @@ -1,4 +1,5 @@ use mingling::picker::parselib::{ParserStyle, WINDOWS_STYLE}; +use mingling::setup::picker::HelpFlagSetup; use tscn_to_bsn::ThisProgram; use tscn_to_bsn::cmd::CommandsSetup; use tscn_to_bsn::res::gd_proj_dir::GodotProjectSetup; @@ -8,6 +9,7 @@ fn main() { ParserStyle::set_global_style(&WINDOWS_STYLE); + program.with_setup(HelpFlagSetup::default()); program.with_setup(CommandsSetup); program.with_setup(GodotProjectSetup); diff --git a/tools/tscn-to-bsn/src/fallback.rs b/tools/tscn-to-bsn/src/fallback.rs new file mode 100644 index 0000000..99bdd13 --- /dev/null +++ b/tools/tscn-to-bsn/src/fallback.rs @@ -0,0 +1,13 @@ +use mingling::macros::{help, renderer}; + +use crate::EntryFallback; + +#[help] +pub fn help_global(_: EntryFallback) -> String { + include_str!("helps/help.txt").to_string() +} + +#[renderer] +pub fn render_global_hint(_: EntryFallback) -> String { + "Error: unknown command, please use `tscn2bsn /H` for help".into() +} diff --git a/tools/tscn-to-bsn/src/helps/help.txt b/tools/tscn-to-bsn/src/helps/help.txt new file mode 100644 index 0000000..3f9c7c2 --- /dev/null +++ b/tools/tscn-to-bsn/src/helps/help.txt @@ -0,0 +1,15 @@ +A simple program for translating Godot 4's TSCN (*.tscn) files + into Bevy 0.19's bsn! macro invocation code. + +USAGE: tscn2bsn [] + +Flags: + /H /Help Show this text + /P /ProjectPath Godot project path + +Commands: + convert /I /O Parse TSCN text into a syntax tree and + output it to a RON file. + + build-cache Collect information about the current + project and build a cache for analysis. diff --git a/tools/tscn-to-bsn/src/lib.rs b/tools/tscn-to-bsn/src/lib.rs index d243e10..b2d80aa 100644 --- a/tools/tscn-to-bsn/src/lib.rs +++ b/tools/tscn-to-bsn/src/lib.rs @@ -2,6 +2,7 @@ use mingling::macros::gen_program; pub mod cmd; pub mod err; +pub mod fallback; pub mod gd_res_structure; pub mod res; -- cgit