forked from platformio/platformio-core
Handle obsoleted commands // Issue #158
This commit is contained in:
@@ -31,9 +31,23 @@ class PlatformioCLI(click.MultiCommand): # pylint: disable=R0904
|
|||||||
mod = __import__("platformio.commands." + name,
|
mod = __import__("platformio.commands." + name,
|
||||||
None, None, ["cli"])
|
None, None, ["cli"])
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
try:
|
||||||
|
return self._handle_obsolate_command(name)
|
||||||
|
except AttributeError:
|
||||||
raise exception.UnknownCLICommand(name)
|
raise exception.UnknownCLICommand(name)
|
||||||
return mod.cli
|
return mod.cli
|
||||||
|
|
||||||
|
def _handle_obsolate_command(self, name):
|
||||||
|
if name in ("install", "list", "search", "show", "uninstall"):
|
||||||
|
click.secho(
|
||||||
|
"Warning! `platformio %s` command is obsoleted! Please use "
|
||||||
|
"`platformio platforms %s`" % (name, name),
|
||||||
|
fg="red"
|
||||||
|
)
|
||||||
|
from platformio.commands import platforms
|
||||||
|
return getattr(platforms, "platforms_" + name)
|
||||||
|
raise AttributeError()
|
||||||
|
|
||||||
|
|
||||||
@click.command(cls=PlatformioCLI)
|
@click.command(cls=PlatformioCLI)
|
||||||
@click.version_option(__version__, prog_name="PlatformIO")
|
@click.version_option(__version__, prog_name="PlatformIO")
|
||||||
|
Reference in New Issue
Block a user