forked from platformio/platformio-core
Fix broken "init" command
This commit is contained in:
@ -91,21 +91,12 @@ def configure():
|
|||||||
click.secho = lambda *args, **kwargs: _safe_echo(1, *args, **kwargs)
|
click.secho = lambda *args, **kwargs: _safe_echo(1, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def remap_command_arguments(argv):
|
|
||||||
if len(argv) > 1 and argv[1] == "init":
|
|
||||||
return argv[:1] + ["project"] + argv[1:]
|
|
||||||
return argv
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
exit_code = 0
|
exit_code = 0
|
||||||
prev_sys_argv = sys.argv[:]
|
prev_sys_argv = sys.argv[:]
|
||||||
if argv:
|
if argv:
|
||||||
assert isinstance(argv, list)
|
assert isinstance(argv, list)
|
||||||
sys.argv = argv
|
sys.argv = argv
|
||||||
else:
|
|
||||||
sys.argv = remap_command_arguments(sys.argv)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
configure()
|
configure()
|
||||||
cli() # pylint: disable=no-value-for-parameter
|
cli() # pylint: disable=no-value-for-parameter
|
||||||
|
@ -63,5 +63,18 @@ class PlatformioCLI(click.MultiCommand):
|
|||||||
mod_path = "platformio.commands.%s.command" % cmd_name
|
mod_path = "platformio.commands.%s.command" % cmd_name
|
||||||
mod = __import__(mod_path, None, None, ["cli"])
|
mod = __import__(mod_path, None, None, ["cli"])
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
try:
|
||||||
|
return self._handle_obsolate_command(cmd_name)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
raise click.UsageError('No such command "%s"' % cmd_name, ctx)
|
raise click.UsageError('No such command "%s"' % cmd_name, ctx)
|
||||||
return mod.cli
|
return mod.cli
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _handle_obsolate_command(name):
|
||||||
|
# pylint: disable=import-outside-toplevel
|
||||||
|
if name == "init":
|
||||||
|
from platformio.commands.project import project_init
|
||||||
|
|
||||||
|
return project_init
|
||||||
|
raise AttributeError()
|
||||||
|
Reference in New Issue
Block a user