Skip to content

Commit 69daadd

Browse files
committed
Support multi file run at same time
1 parent 633f1e7 commit 69daadd

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ CAIE Pseudocode Interpreter
2828

2929
### Usage
3030
```
31-
cpc [file_path] [options]
31+
cpc [file_paths] [options]
3232
```
3333

3434
### Options

main.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def wrong_argument(msg):
154154
# 主函数
155155
def main():
156156
# 解析参数
157-
file_path = ''
157+
file_paths = set()
158158
i = 1
159159
while i < len(argv):
160160
arg = argv[i]
@@ -167,27 +167,26 @@ def main():
167167
if arg[0] == '-':
168168
wrong_argument(f'Unknown option `{arg}`')
169169
else:
170-
if file_path == '':
171-
file_path = arg
172-
else:
173-
wrong_argument(f'There should only be one file path, but found `{file_path}` and `{arg}`')
170+
file_paths.add(arg)
174171
i += 1
175172

176173
# 预加载文件
177174
preload_scripts()
178175

179-
lexer.lineno = 1
180176
# 选择模式运行
181-
if not file_path:
177+
if not file_paths:
182178
with_line()
183179
else:
184-
if os.path.exists(file_path):
185-
if os.path.isfile(file_path):
186-
with_file(file_path)
180+
for file_path in file_paths:
181+
lexer.lineno = 1
182+
# 选择模式运行
183+
if os.path.exists(file_path):
184+
if os.path.isfile(file_path):
185+
with_file(file_path)
186+
else:
187+
wrong_argument(f'`{file_path}` is not a file')
187188
else:
188-
wrong_argument(f'`{file_path}` is not a file')
189-
else:
190-
wrong_argument(f'File `{file_path}` does not exist')
189+
wrong_argument(f'File `{file_path}` does not exist')
191190

192191

193192
# 程序入口

man/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pandoc man/cpc.md -s -t man -o man/cpc.1

man/cpc.1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
cpc - An interpreter for CAIE Pseudocode.
2222
.SH SYNOPSIS
2323
.PP
24-
\f[B]cpc\f[R] [\f[I]FILE_PATH\f[R]] [\f[I]OPTIONS\f[R]]
24+
\f[B]cpc\f[R] [\f[I]FILE_PATHS\f[R]] [\f[I]OPTIONS\f[R]]
2525
.SH DESCRIPTION
2626
.PP
2727
\f[B]cpc\f[R] is a simple interpreter for CAIE Pseudocode written in
@@ -69,6 +69,9 @@ git)
6969
\f[B]-v\f[R]
7070
\f[B]\[en]version\f[R]
7171
To show the version of installed \f[I]cpc\f[R]
72+
.SS EXAMPLE
73+
.PP
74+
\f[I]cpc test/test.cpc test/recursive_test.cpc -r 10000 -t -gt\f[R]
7275
.SH PLAYGROUND OPTIONS
7376
.TP
7477
\f[B]clear\f[R]

man/cpc.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ date: September 8, 2023
1010
cpc - An interpreter for CAIE Pseudocode.
1111

1212
# SYNOPSIS
13-
**cpc** [*FILE_PATH*] [*OPTIONS*]
13+
**cpc** [*FILE_PATHS*] [*OPTIONS*]
1414

1515
# DESCRIPTION
1616
**cpc** is a simple interpreter for CAIE Pseudocode written in Python3. The language regulated by CAIE has a really retro grammar and even some grammar is not good for both developers and the interpreter. Thus, some unimportant grammars are changed in this interpreter. For more detailed information about this, you may look at README or <https://github.com/iewnfod/CAIE_Code>.
@@ -52,6 +52,9 @@ cpc - An interpreter for CAIE Pseudocode.
5252
: **--version**
5353
: To show the version of installed *cpc*
5454

55+
## EXAMPLE
56+
*cpc test/test.cpc test/recursive_test.cpc -r 10000 -t -gt*
57+
5558
# PLAYGROUND OPTIONS
5659
**clear**
5760
: To remove all commands before in the playground

src/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ def help():
3434

3535
print()
3636

37-
print('Usage: \033[1mcpc\033[0m [file_path] [options]')
37+
print('Usage: \033[1mcpc\033[0m [file_paths] [options]')
3838

3939
# 提示
40-
print('\033[2mThere should not be any space in a file path. \nOr, you need to add double quotation marks around the path. \033[0m')
40+
print('\033[2mThere should not be any space in a single file path. \nOr, you need to add double quotation marks around the path. \033[0m')
4141

4242
print()
4343

0 commit comments

Comments
 (0)