Skip to content

Commit 0647653

Browse files
committed
pass of args for clap, pop first arg
1 parent 302784d commit 0647653

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ fn main() {
4343
.takes_value(true)
4444
.help("run library module as script"),
4545
)
46+
.arg(Arg::from_usage("[pyargs] 'args for python'")
47+
.multiple(true)
48+
)
4649
.get_matches();
4750

4851
// Construct vm:

tests/snippets/sysmod_argv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import sys
22

3-
print(sys.argv[1])
4-
3+
print(sys.argv)
4+
assert sys.argv[0].endswith('.py')

vm/src/sysmodule.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use super::vm::VirtualMachine;
77
*/
88

99
fn argv(ctx: &PyContext) -> PyObjectRef {
10-
let argv: Vec<PyObjectRef> = env::args().map(|x| ctx.new_str(x)).collect();
10+
let mut argv: Vec<PyObjectRef> = env::args().map(|x| ctx.new_str(x)).collect();
11+
argv.remove(0);
1112
ctx.new_list(argv)
1213
}
1314

0 commit comments

Comments
 (0)