Commit 8fb4f452 by Sébastien Eustace

Revert "Remove the custom logic for the run command"

This reverts commit 65ba952f.
parent 9addba4d
from clikit.api.args import Args
from clikit.api.args import RawArgs
from clikit.api.args.format import ArgsFormat
from clikit.api.args.format import ArgsFormatBuilder
from clikit.args import DefaultArgsParser
class RunArgsParser(DefaultArgsParser):
"""
Parser that just parses command names and leave the rest
alone to be passed to the command.
"""
def parse(
self, args, fmt, lenient=False
): # type: (RawArgs, ArgsFormat, bool) -> Args
builder = ArgsFormatBuilder()
builder.set_command_names(*fmt.get_command_names())
builder.set_arguments(*fmt.get_arguments().values())
fmt = builder.format
return super(RunArgsParser, self).parse(args, fmt, True)
def _parse(
self, raw_args, fmt, lenient
): # type: (RawArgs, ArgsFormat, bool) -> None
"""
Parse everything as a single, multi-valued argument.
"""
tokens = raw_args.tokens[:]
last_arg = list(fmt.get_arguments().values())[-1]
self._arguments[last_arg.name] = []
while True:
try:
token = tokens.pop(0)
except IndexError:
break
self._arguments[last_arg.name].append(token)
...@@ -12,6 +12,13 @@ class RunCommand(EnvCommand): ...@@ -12,6 +12,13 @@ class RunCommand(EnvCommand):
argument("args", "The command and arguments/options to run.", multiple=True) argument("args", "The command and arguments/options to run.", multiple=True)
] ]
def __init__(self): # type: () -> None
from poetry.console.args.run_args_parser import RunArgsParser
super(RunCommand, self).__init__()
self.config.set_args_parser(RunArgsParser())
def handle(self): def handle(self):
args = self.argument("args") args = self.argument("args")
script = args[0] script = args[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment