Skip to content

Commit caa69a4

Browse files
committed
Use mutex group for --args|cmd and fix cmd to use a list type.
1 parent f5a8abd commit caa69a4

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

gdbgui/backend.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ def main():
761761
parser = argparse.ArgumentParser(description=__doc__)
762762

763763
gdb_group = parser.add_argument_group(title="gdb commands")
764+
args_group = parser.add_mutually_exclusive_group()
764765
network = parser.add_argument_group(title="gdbgui network settings")
765766
security = parser.add_argument_group(title="security settings")
766767
other = parser.add_argument_group(title="other settings")
@@ -853,22 +854,23 @@ def main():
853854
action="store_true",
854855
)
855856

856-
gdb_group.add_argument(
857+
args_group.add_argument(
858+
"cmd",
859+
nargs='?',
860+
type=lambda prog : [prog],
861+
help='Name of the binary to run in gdb. To pass flags to the binary,'
862+
' use --args instead.'
863+
' Example: gdbgui ./mybinary [gdbgui-args...]',
864+
default=[],
865+
)
866+
args_group.add_argument(
857867
"--args",
858868
nargs=argparse.REMAINDER,
859869
help='All remaining args are taken as the binary and arguments to run'
860870
' in gdb (as with gdb --args).'
861871
' Example: gdbgui [...] --args ./mybinary myarg -flag1 -flag2',
862872
default=[],
863873
)
864-
gdb_group.add_argument(
865-
"cmd",
866-
nargs='?',
867-
help='Name of the binary to run in gdb. To pass flags to the binary,'
868-
' use --args.'
869-
' Example: gdbgui ./mybinary [gdbgui-args...]',
870-
default=[],
871-
)
872874

873875
args = parser.parse_args()
874876

@@ -878,13 +880,7 @@ def main():
878880
print(__version__)
879881
return
880882

881-
if args.cmd and args.args:
882-
print("Cannot specify command and args. Must specify one or the other.")
883-
exit(1)
884-
if args.cmd:
885-
cmd = args.cmd
886-
else:
887-
cmd = args.args
883+
cmd = args.cmd or args.args
888884

889885
app.config["initial_binary_and_args"] = cmd
890886
app.config["rr"] = args.rr

0 commit comments

Comments
 (0)