Added platforms frame logic; implemented "install" and "run" commands

This commit is contained in:
Ivan Kravets
2014-06-07 13:34:31 +03:00
parent 64dbdd76ad
commit 937c38a7b7
14 changed files with 585 additions and 51 deletions

View File

@@ -1,21 +1,24 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.
from click import command, echo, option, style
from click import command, echo, option, secho, style
from platformio.util import get_project_config, run_builder, textindent
from platformio.exception import UndefinedEnvPlatform
from platformio.platforms.base import PlatformFactory
from platformio.util import get_project_config
@command("run", short_help="Process project environments")
@option("--environment", "-e", multiple=True)
@option("--target", "-t", multiple=True)
def cli(environment, target):
config = get_project_config()
for section in config.sections():
if section[:4] != "env:":
continue
envname = section[4:]
envname = section[4:]
if environment and envname not in environment:
echo("Skipped %s environment" % style(envname, fg="yellow"))
continue
@@ -31,6 +34,10 @@ def cli(environment, target):
elif config.has_option(section, "targets"):
envtargets = config.get(section, "targets").split()
result = run_builder(variables, envtargets)
echo(textindent(style(result['out'], fg="green"), ". "))
echo(textindent(style(result['err'], fg="red"), ". "))
if not config.has_option(section, "platform"):
raise UndefinedEnvPlatform(envname)
p = PlatformFactory().newPlatform(config.get(section, "platform"))
result = p.run(variables, envtargets)
secho(result['out'], fg="green")
secho(result['err'], fg="red")