summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--subcmds/forall.py3
-rw-r--r--tests/test_subcmds.py7
2 files changed, 8 insertions, 2 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py
index 4bae46af..57a41fc1 100644
--- a/subcmds/forall.py
+++ b/subcmds/forall.py
@@ -133,7 +133,7 @@ without iterating through the remaining projects.
133 133
134 @staticmethod 134 @staticmethod
135 def _cmd_option(option, _opt_str, _value, parser): 135 def _cmd_option(option, _opt_str, _value, parser):
136 setattr(parser.values, option.dest or "command", list(parser.rargs)) 136 setattr(parser.values, option.dest, list(parser.rargs))
137 while parser.rargs: 137 while parser.rargs:
138 del parser.rargs[0] 138 del parser.rargs[0]
139 139
@@ -161,6 +161,7 @@ without iterating through the remaining projects.
161 p.add_option( 161 p.add_option(
162 "-c", 162 "-c",
163 "--command", 163 "--command",
164 dest="command",
164 help="command (and arguments) to execute", 165 help="command (and arguments) to execute",
165 action="callback", 166 action="callback",
166 callback=self._cmd_option, 167 callback=self._cmd_option,
diff --git a/tests/test_subcmds.py b/tests/test_subcmds.py
index 2d680fb7..0683f1dd 100644
--- a/tests/test_subcmds.py
+++ b/tests/test_subcmds.py
@@ -94,7 +94,12 @@ class AllCommands(unittest.TestCase):
94 """Block redundant dest= arguments.""" 94 """Block redundant dest= arguments."""
95 95
96 def _check_dest(opt): 96 def _check_dest(opt):
97 if opt.dest is None or not opt._long_opts: 97 """Check the dest= setting."""
98 # If the destination is not set, nothing to check.
99 # If long options are not set, then there's no implicit destination.
100 # If callback is used, then a destination might be needed because
101 # optparse cannot assume a value is always stored.
102 if opt.dest is None or not opt._long_opts or opt.callback:
98 return 103 return
99 104
100 long = opt._long_opts[0] 105 long = opt._long_opts[0]