diff --git a/platformio/__main__.py b/platformio/__main__.py index 6679d52e..4358e4fe 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -91,12 +91,21 @@ def configure(): 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): exit_code = 0 prev_sys_argv = sys.argv[:] if argv: assert isinstance(argv, list) sys.argv = argv + else: + sys.argv = remap_command_arguments(sys.argv) + try: configure() cli() # pylint: disable=no-value-for-parameter diff --git a/platformio/commands/__init__.py b/platformio/commands/__init__.py index f6bac830..bc018f8c 100644 --- a/platformio/commands/__init__.py +++ b/platformio/commands/__init__.py @@ -63,18 +63,5 @@ class PlatformioCLI(click.MultiCommand): mod_path = "platformio.commands.%s.command" % cmd_name mod = __import__(mod_path, None, None, ["cli"]) except ImportError: - try: - return self._handle_obsolate_command(cmd_name) - except AttributeError: - pass raise click.UsageError('No such command "%s"' % cmd_name, ctx) 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() diff --git a/platformio/telemetry.py b/platformio/telemetry.py index f765e06d..ddb12f60 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -142,14 +142,7 @@ class MeasurementProtocol(TelemetryBase): return cmd_path = args[:1] - if args[0] in ( - "platform", - "platforms", - "serialports", - "device", - "settings", - "account", - ): + if args[0] in ("account", "device", "platform", "project", "settings",): cmd_path = args[:2] if args[0] == "lib" and len(args) > 1: lib_subcmds = (