forked from platformio/platformio-core
Implemented new commands: list, show, uninstall & update; minor improvements to code
This commit is contained in:
1 parent
bddb9237e2
commit
027c3d0e5e
9 files changed
+192
-38
No files matched your search
@@ -6,7 +6,7 @@ from click import argument, command, option, secho
|
||||
from platformio.platforms._base import PlatformFactory
|
||||
|
||||
|
||||
@command("run", short_help="Install new platforms")
|
||||
@command("install", short_help="Install new platforms")
|
||||
@argument("platform")
|
||||
@option('--with-package', multiple=True, metavar="<package>")
|
||||
@option('--without-package', multiple=True, metavar="<package>")
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
from click import command, echo, style
|
||||
|
||||
from platformio.pkgmanager import PackageManager
|
||||
|
||||
|
||||
@command("list", short_help="List installed platforms")
|
||||
def cli():
|
||||
|
||||
for name, pkgs in PackageManager.get_installed().iteritems():
|
||||
echo("{name:<20} with packages: {pkgs}".format(
|
||||
name=style(name, fg="cyan"),
|
||||
pkgs=", ".join(pkgs.keys())
|
||||
))
|
||||
@@ -0,0 +1,29 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
from os.path import join
|
||||
|
||||
from click import argument, command, echo, style
|
||||
|
||||
from platformio.exception import PlatformNotInstalledYet
|
||||
from platformio.pkgmanager import PackageManager
|
||||
from platformio.platforms._base import PlatformFactory
|
||||
|
||||
|
||||
@command("show", short_help="Show details about an installed platforms")
|
||||
@argument("platform")
|
||||
def cli(platform):
|
||||
p = PlatformFactory().newPlatform(platform)
|
||||
if platform not in PackageManager.get_installed():
|
||||
raise PlatformNotInstalledYet(platform)
|
||||
|
||||
# print info about platform
|
||||
echo("{name:<20} - {info}".format(name=style(p.get_name(), fg="cyan"),
|
||||
info=p.get_short_info()))
|
||||
|
||||
pm = PackageManager(platform)
|
||||
for name, data in pm.get_installed(platform).iteritems():
|
||||
echo("----------")
|
||||
echo("Package: %s" % style(name, fg="yellow"))
|
||||
echo("Location: %s" % join(pm.get_platform_dir(), data['path']))
|
||||
echo("Version: %d" % int(data['version']))
|
||||
@@ -0,0 +1,21 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
from click import argument, command, secho
|
||||
|
||||
from platformio.exception import PlatformNotInstalledYet
|
||||
from platformio.pkgmanager import PackageManager
|
||||
from platformio.platforms._base import PlatformFactory
|
||||
|
||||
|
||||
@command("uninstall", short_help="Uninstall the platforms")
|
||||
@argument("platform")
|
||||
def cli(platform):
|
||||
|
||||
if platform not in PackageManager.get_installed():
|
||||
raise PlatformNotInstalledYet(platform)
|
||||
|
||||
p = PlatformFactory().newPlatform(platform)
|
||||
if p.uninstall():
|
||||
secho("The platform '%s' has been successfully "
|
||||
"uninstalled!" % platform, fg="green")
|
||||
@@ -0,0 +1,17 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
from click import command, echo, style
|
||||
|
||||
from platformio.pkgmanager import PackageManager
|
||||
from platformio.platforms._base import PlatformFactory
|
||||
|
||||
|
||||
@command("update", short_help="Update installed platforms")
|
||||
def cli():
|
||||
|
||||
for platform in PackageManager.get_installed().keys():
|
||||
echo("\nPlatform %s" % style(platform, fg="cyan"))
|
||||
echo("--------")
|
||||
p = PlatformFactory().newPlatform(platform)
|
||||
p.update()
|
||||
Reference in new issue
Block a user