2014-06-13 20:47:02 +03:00
|
|
|
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
|
|
|
# See LICENSE for details.
|
|
|
|
|
2014-11-22 23:55:17 +02:00
|
|
|
from datetime import datetime
|
2014-06-13 20:47:02 +03:00
|
|
|
|
|
|
|
from click import argument, command, echo, style
|
|
|
|
|
|
|
|
from platformio.exception import PlatformNotInstalledYet
|
|
|
|
from platformio.pkgmanager import PackageManager
|
2014-07-30 22:40:11 +03:00
|
|
|
from platformio.platforms.base import PlatformFactory
|
2014-06-13 20:47:02 +03:00
|
|
|
|
|
|
|
|
2014-09-04 18:57:13 +03:00
|
|
|
@command("show", short_help="Show details about installed platforms")
|
2014-06-13 20:47:02 +03:00
|
|
|
@argument("platform")
|
|
|
|
def cli(platform):
|
2014-11-22 23:55:17 +02:00
|
|
|
|
|
|
|
installed_platforms = PlatformFactory.get_platforms(
|
|
|
|
installed=True).keys()
|
|
|
|
|
|
|
|
if platform not in installed_platforms:
|
2014-12-03 20:15:52 +02:00
|
|
|
if click.confirm("The platform '%s' has not been installed yet. "
|
|
|
|
"Would you like to install it now?" % platform):
|
|
|
|
ctx.invoke(cmd_install, platforms=[platform])
|
|
|
|
else:
|
|
|
|
raise PlatformNotInstalledYet(platform)
|
2014-06-13 20:47:02 +03:00
|
|
|
|
2014-11-22 23:55:17 +02:00
|
|
|
p = PlatformFactory().newPlatform(platform)
|
2014-06-13 20:47:02 +03:00
|
|
|
echo("{name:<20} - {info}".format(name=style(p.get_name(), fg="cyan"),
|
|
|
|
info=p.get_short_info()))
|
|
|
|
|
2014-11-22 23:55:17 +02:00
|
|
|
installed_packages = PackageManager.get_installed()
|
|
|
|
for name in p.get_installed_packages():
|
|
|
|
data = installed_packages[name]
|
2014-07-30 23:39:01 +03:00
|
|
|
pkgalias = p.get_pkg_alias(name)
|
2014-06-13 20:47:02 +03:00
|
|
|
echo("----------")
|
|
|
|
echo("Package: %s" % style(name, fg="yellow"))
|
2014-07-30 23:39:01 +03:00
|
|
|
if pkgalias:
|
|
|
|
echo("Alias: %s" % pkgalias)
|
2014-06-13 20:47:02 +03:00
|
|
|
echo("Version: %d" % int(data['version']))
|
2014-11-22 23:55:17 +02:00
|
|
|
echo("Installed: %s" % datetime.fromtimestamp(
|
|
|
|
data['time']).strftime("%Y-%m-%d %H:%M:%S"))
|