File tree Expand file tree Collapse file tree 1 file changed +25
-7
lines changed
Expand file tree Collapse file tree 1 file changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -19,27 +19,34 @@ use Parser;
1919use Generator;
2020
2121sub USAGE () {
22+ usage;
23+ }
24+
25+ sub usage () {
2226 print q :to /END /;
23- Usage: rawstr4c <FILE.md|DIR> [--debug] [--help]
27+ Usage: rawstr4c [--debug] [--help] <FILE.md|DIR>
2428
2529 Arguments:
2630 FILE.md Process a specific markdown file
2731 DIR Process rawstr4c.md file in the given directory
2832
2933 Options:
3034 --debug Show debug information during processing
35+ Value can be [generator|parser]. Default to generator.
36+
3137 --help Show this help message
3238
3339 Error: Unknown option or invalid arguments provided.
3440 END
35- exit (1 );
3641}
3742
43+
3844sub MAIN (
3945 # 一定要声明为必选,强制用户输入,未输入时直接进入 USAGE
40- Str $ input-path ,
41- Bool : $ debug = False , # = --debug
42- Bool : $ help # = 命令行指定 --help 的时候强制进入 USAGE
46+ Str $ input-path ,
47+ # 如果是 Str 类型,则 --debug 缺少命令行参数
48+ # 如果是 Any 类型,则可以直接使用 --debug,值为 True
49+ Any : $ debug ,
4350)
4451{
4552 my $ markdown-file ;
@@ -61,7 +68,18 @@ sub MAIN(
6168
6269 my $ parser = Parser::Parser. new ($ markdown-file . Str );
6370 $ parser . parse;
64- $ parser . debug-print-summary if $ debug ;
6571
66- Generator::Generator. new ($ parser ). generate;
72+ my $ generator = Generator::Generator. new ($ parser );
73+
74+ if ($ debug . defined ) {
75+ given $ debug {
76+ when ' parser' {
77+ $ parser . debug;
78+ }
79+ default {
80+ $ generator . debug;
81+ }
82+ }
83+ }
84+ $ generator . generate;
6785}
You can’t perform that action at this time.
0 commit comments