Skip to content

Commit 6ddd780

Browse files
ValekoZhugsy
andauthoredJun 24, 2024··
[internal] Add a way to append values to optional arguments in parse_arguments decorator (#1122)
Add support for the `append` action for ArgumentParser in the `parse_arguments` decorator on optional arguments. This makes us able to support this: ``` command --arg 1 --arg 2 --arg 3 ``` And get `[1, 2, 3]` as the `arg` value. This CL is required to make changes to #1120 before merging. --------- Co-authored-by: crazy hugsy <hugsy@users.noreply.github.com>
1 parent c450a2d commit 6ddd780

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
 

‎gef.py

+4
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ def wrapper(*args: Any, **kwargs: Any) -> Callable:
491491
elif argtype is bool:
492492
parser.add_argument(*argname, action="store_false" if argvalue else "store_true")
493493
continue
494+
elif argtype in (list, tuple):
495+
parser.add_argument(*argname, type=type(argvalue[0]),
496+
default=[], action="append")
497+
continue
494498
parser.add_argument(*argname, type=argtype, default=argvalue)
495499

496500
parsed_args = parser.parse_args(*(args[1:]))

0 commit comments

Comments
 (0)
Please sign in to comment.