feat: 添加全局调试选项并更新相关功能
- 在 CLIUtils 中添加了全局调试标志集合,支持 "-debug" 和 "--debug" 选项 - 在 CompileTask 中更新了调试选项的处理逻辑,支持新的 "--debug" 标志 - 在 SnowCLI 中引入了 Mode 和 SnowConfig 类,以支持调试模式的配置
This commit is contained in:
parent
ebc322668e
commit
210fdb62f0
@ -4,6 +4,8 @@ import org.jcnc.snow.cli.api.CLICommand;
|
|||||||
import org.jcnc.snow.cli.commands.*;
|
import org.jcnc.snow.cli.commands.*;
|
||||||
import org.jcnc.snow.cli.utils.CLIUtils;
|
import org.jcnc.snow.cli.utils.CLIUtils;
|
||||||
import org.jcnc.snow.cli.utils.VersionUtils;
|
import org.jcnc.snow.cli.utils.VersionUtils;
|
||||||
|
import org.jcnc.snow.common.Mode;
|
||||||
|
import org.jcnc.snow.common.SnowConfig;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|||||||
@ -26,12 +26,21 @@ public class CLIUtils {
|
|||||||
"-v", "--version"
|
"-v", "--version"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局调试标志集合,支持 "-debug"、"--debug"。
|
||||||
|
*/
|
||||||
|
public static final Set<String> GLOBAL_DEBUG_FLAGS = Set.of(
|
||||||
|
"--debug"
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局选项列表,包括帮助和版本选项的描述。
|
* 全局选项列表,包括帮助和版本选项的描述。
|
||||||
*/
|
*/
|
||||||
public static final List<Option> GLOBAL_OPTIONS = List.of(
|
public static final List<Option> GLOBAL_OPTIONS = List.of(
|
||||||
new Option(List.of("-h", "--help"), "Show this help message and exit"),
|
new Option(List.of("-h", "--help"), "Show this help message and exit"),
|
||||||
new Option(List.of("-v", "--version"), "Print snow programming language version and exit")
|
new Option(List.of("-v", "--version"), "Print snow programming language version and exit"),
|
||||||
|
new Option(List.of("-debug", "--debug"), "Enable debug mode with verbose internal logs")
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -154,7 +154,7 @@ public final class CompileTask implements Task {
|
|||||||
String arg = args[i];
|
String arg = args[i];
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case "run" -> runAfterCompile = true;
|
case "run" -> runAfterCompile = true;
|
||||||
case "-debug" -> SnowConfig.MODE = Mode.DEBUG;
|
case "-debug", "--debug" -> SnowConfig.MODE = Mode.DEBUG;
|
||||||
case "-o" -> {
|
case "-o" -> {
|
||||||
if (i + 1 < args.length) outputName = args[++i];
|
if (i + 1 < args.length) outputName = args[++i];
|
||||||
else {
|
else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user