Skip to content

Commit d323b0b

Browse files
committed
Fix #258
1 parent 1f41cf6 commit d323b0b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/cleo/application.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,32 @@ def _run(self, io: IO) -> int:
428428
io.input.set_stream(stream)
429429
io.input.interactive(interactive)
430430

431+
if name == "help" and isinstance(io.input, ArgvInput):
432+
# If the command is `help` we suppose
433+
# that all without `-` is a command (possible namespaced)
434+
argv = io.input._tokens[:]
435+
436+
if io.input.script_name is not None:
437+
argv.insert(0, io.input.script_name)
438+
else:
439+
# Needs because `ApplicationTester` doesn't add script name
440+
argv.insert(0, self.name)
441+
442+
# filter all words after `help` without `-`
443+
start = argv.index(name)
444+
words = list(filter(lambda arg: "-" not in arg, argv[start + 1 :]))
445+
446+
if words:
447+
index = argv.index(words[0])
448+
argv[index] = " ".join(argv[index:])
449+
del argv[index + 1 :]
450+
451+
stream = io.input.stream
452+
interactive = io.input.is_interactive()
453+
io.set_input(ArgvInput(argv))
454+
io.input.set_stream(stream)
455+
io.input.interactive(interactive)
456+
431457
exit_code = self._run_command(command, io)
432458
self._running_command = None
433459

0 commit comments

Comments
 (0)