Skip to content

Commit

Permalink
Fix #258
Browse files Browse the repository at this point in the history
  • Loading branch information
ZettZet committed Jan 4, 2023
1 parent 714390a commit 803f819
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/cleo/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,32 @@ def _run(self, io: IO) -> int:
io.input.set_stream(stream)
io.input.interactive(interactive)

if name == "help" and isinstance(io.input, ArgvInput):
# If the command is `help` we suppose
# that all without `-` is a command (possible namespaced)
argv = io.input._tokens[:]

if io.input.script_name is not None:
argv.insert(0, io.input.script_name)
else:
# Needs because `ApplicationTester` doesn't add script name
argv.insert(0, self.name)

# filter all words after `help` without `-`
start = argv.index(name)
words = list(filter(lambda arg: "-" not in arg, argv[start + 1 :]))

if words:
index = argv.index(words[0])
argv[index] = " ".join(argv[index:])
del argv[index + 1 :]

stream = io.input.stream
interactive = io.input.is_interactive()
io.set_input(ArgvInput(argv))
io.input.set_stream(stream)
io.input.interactive(interactive)

exit_code = self._run_command(command, io)
self._running_command = None

Expand Down

0 comments on commit 803f819

Please sign in to comment.