Skip to content

Commit

Permalink
Add new setting enable_prompts and avoid blocking / Resolve #34
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Dec 10, 2014
1 parent 2b2ceb6 commit 3157cea
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 6 deletions.
9 changes: 9 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Release History
===============

0.9.2 (?)
---------

* Replaced "dark blue" by "cyan" colour for the texts (`issue #33 <https://github.com/ivankravets/platformio/issues/33>`_)
* Added new setting `enable_prompts <http://docs.platformio.ikravets.com/en/latest/userguide/cmd_settings.html>`_
and allowed to disable all PlatformIO prompts (useful for cloud compilers)
(`issue #34 <https://github.com/ivankravets/platformio/issues/34>`_)


0.9.1 (2014-12-05)
------------------

Expand Down
5 changes: 5 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ application:
`Command Prompt <http://en.wikipedia.org/wiki/Command_Prompt>`_ (``cmd.exe``)
application.

.. warning::
If you are going to use *PlatformIO* for "*Cloud Compiling*", please
don't forget to turn off :ref:`enable_prompts <cmd_settings>` setting. It
will allow you to avoid blocking when call ``platformio`` like subprocess.

Please *choose one of* the following:

Super-Quick (Mac / Linux)
Expand Down
9 changes: 9 additions & 0 deletions platformio/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
"description": ("Shares commands, platforms and libraries usage"
" to help us make PlatformIO better (Yes/No)"),
"value": True
},
"enable_prompts": {
"description": (
"Can PlatformIO communicate with you via prompts: "
"propose to install platforms which aren't installed yet, "
"paginate over library search results and etc.)? ATTENTION!!! "
"If you call PlatformIO like subprocess, "
"please disable prompts to avoid blocking (Yes/No)"),
"value": True
}
}

Expand Down
4 changes: 3 additions & 1 deletion platformio/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import click

from platformio import app
from platformio.exception import ProjectInitialized
from platformio.util import get_source_dir

Expand Down Expand Up @@ -42,7 +43,8 @@ def cli(project_dir):
click.echo("%s - a directory for the project specific libraries" %
click.style("lib", fg="cyan"))

if click.confirm("Do you want to continue?"):
if (not app.get_setting("enable_prompts") or
click.confirm("Do you want to continue?")):
for d in (src_dir, lib_dir):
if not isdir(d):
makedirs(d)
Expand Down
4 changes: 3 additions & 1 deletion platformio/commands/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import click

from platformio import app
from platformio.exception import (LibAlreadyInstalledError,
LibInstallDependencyError)
from platformio.libmanager import LibraryManager
Expand Down Expand Up @@ -69,7 +70,8 @@ def lib_search(query, **filters):
if int(result['page'])*int(result['perpage']) >= int(result['total']):
break

if click.confirm("Show next libraries?"):
if (app.get_setting("enable_prompts") and
click.confirm("Show next libraries?")):
result = get_api_result(
"/lib/search",
dict(query=query, page=str(int(result['page']) + 1))
Expand Down
5 changes: 3 additions & 2 deletions platformio/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import click

from platformio import exception, telemetry
from platformio import app, exception, telemetry
from platformio.commands.install import cli as cmd_install
from platformio.platforms.base import PlatformFactory
from platformio.util import get_project_config
Expand Down Expand Up @@ -68,7 +68,8 @@ def process_environment(ctx, name, options, targets, upload_port):

telemetry.on_run_environment(options, envtargets)

if (platform not in PlatformFactory.get_platforms(installed=True) and
if (app.get_setting("enable_prompts") and
platform not in PlatformFactory.get_platforms(installed=True) and
click.confirm("The platform '%s' has not been installed yet. "
"Would you like to install it now?" % platform)):
ctx.invoke(cmd_install, platforms=[platform])
Expand Down
6 changes: 4 additions & 2 deletions platformio/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import click

from platformio import app
from platformio.commands.install import cli as cmd_install
from platformio.exception import PlatformNotInstalledYet
from platformio.pkgmanager import PackageManager
Expand All @@ -20,8 +21,9 @@ def cli(ctx, platform):
installed=True).keys()

if platform not in installed_platforms:
if click.confirm("The platform '%s' has not been installed yet. "
"Would you like to install it now?" % platform):
if (app.get_setting("enable_prompts") and
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)
Expand Down

0 comments on commit 3157cea

Please sign in to comment.