From dd2d14743ea75f0e6f468403ab45db0e07cda7df Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 18 Jun 2025 10:05:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E4=BB=8E=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=96=87=E4=BB=B6=E4=B8=AD=E5=8A=A0=E8=BD=BD=20Snow?= =?UTF-8?q?=20=E7=BC=96=E7=A8=8B=E8=AF=AD=E8=A8=80=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 +- .../org/jcnc/snow/compiler/cli/SnowCLI.java | 108 ++++++------------ .../compiler/cli/commands/VersionCommand.java | 3 +- .../snow/compiler/cli/utils/CLIUtils.java | 70 ++++++++++++ .../snow/compiler/cli/utils/VersionUtils.java | 41 +++++++ src/main/resources/version.properties | 1 + 6 files changed, 155 insertions(+), 78 deletions(-) create mode 100644 src/main/java/org/jcnc/snow/compiler/cli/utils/CLIUtils.java create mode 100644 src/main/java/org/jcnc/snow/compiler/cli/utils/VersionUtils.java create mode 100644 src/main/resources/version.properties diff --git a/pom.xml b/pom.xml index edc8a5d..3072111 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.jcnc.snow Snow - 1.0-SNAPSHOT + 0.4.0 24 @@ -17,6 +17,13 @@ + + + src/main/resources + true + + + @@ -37,6 +44,7 @@ org.jcnc.snow.compiler.cli.SnowCLI true + true diff --git a/src/main/java/org/jcnc/snow/compiler/cli/SnowCLI.java b/src/main/java/org/jcnc/snow/compiler/cli/SnowCLI.java index 54c7e1a..5846980 100644 --- a/src/main/java/org/jcnc/snow/compiler/cli/SnowCLI.java +++ b/src/main/java/org/jcnc/snow/compiler/cli/SnowCLI.java @@ -3,40 +3,31 @@ package org.jcnc.snow.compiler.cli; import org.jcnc.snow.compiler.cli.commands.CompileCommand; import org.jcnc.snow.compiler.cli.commands.RunCommand; import org.jcnc.snow.compiler.cli.commands.VersionCommand; +import org.jcnc.snow.compiler.cli.utils.CLIUtils; +import org.jcnc.snow.compiler.cli.utils.VersionUtils; import java.util.Arrays; -import java.util.List; import java.util.Map; -import java.util.Set; import java.util.function.Supplier; /** - * SnowCLI 是项目的命令行入口类,负责解析用户输入、 - * 分发子命令,并统一处理帮助、版本和错误输出。 + * Snow 编程语言的命令行接口入口类。 + *

+ * 该类解析用户输入的命令行参数,调度相应的子命令(compile、run、version), + * 并处理全局帮助和版本信息输出。 + *

*/ public class SnowCLI { - /** Snow 编程语言的版本号。 */ - public static final String SNOW_VERSION = "1.0.0"; - - /** 全局帮助标志,当输入匹配时显示帮助信息。 */ - private static final Set GLOBAL_HELP_FLAGS = Set.of("help", "-h", "--help"); - - /** 全局版本标志,当输入匹配时显示版本信息。 */ - private static final Set GLOBAL_VERSION_FLAGS = Set.of("-v", "--version"); /** - * 全局选项定义列表。 - * 每个 Option 包含可用标志列表及对应的描述信息。 + * Snow 编程语言的当前版本号,从资源文件中加载。 */ - private static final List