diff --git a/HISTORY.rst b/HISTORY.rst index 6f289027..6be89824 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -67,6 +67,7 @@ PlatformIO 3.0 * Removed ``enable_prompts`` setting. Now, all PlatformIO CLI is non-blocking! * Switched to SSL PlatformIO API +* Renamed ``platformio serialports`` command to ``platformio device`` * Build System: Attach custom Before/Pre and After/Post actions for targets (`issue #542 `_) * Print human-readable information when processing environments without diff --git a/docs/index.rst b/docs/index.rst index 387fd68e..abea5247 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -55,7 +55,7 @@ Embedded Development. *Easier Than Ever.* * :ref:`IDE Integration ` with *Arduino, Atom, CLion, Eclipse, Emacs, Energia, Qt Creator, Sublime Text, Vim, Visual Studio* * Cloud compiling and :ref:`ci` with *AppVeyor, Circle CI, Drone, Shippable, Travis CI* -* Built-in :ref:`Serial Port Monitor ` and +* Built-in :ref:`Serial Port Monitor ` and configurable build :ref:`-flags/-options ` * Pre-built toolchains, :ref:`frameworks` for the :ref:`platforms` diff --git a/docs/projectconf.rst b/docs/projectconf.rst index bf182302..dd2c2c0a 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -647,7 +647,7 @@ This option is used by "uploader" tool when sending firmware to board via If ``upload_port`` isn't specified, then *PlatformIO* will try to detect it automatically. -To print all available serial ports use :ref:`cmd_serialports` command. +To print all available serial ports use :ref:`cmd_device` command. This option can be set by global environment variable :envvar:`PLATFORMIO_UPLOAD_PORT`. diff --git a/docs/userguide/cmd_serialports.rst b/docs/userguide/cmd_device.rst similarity index 91% rename from docs/userguide/cmd_serialports.rst rename to docs/userguide/cmd_device.rst index 882a5f02..91d2fcd2 100644 --- a/docs/userguide/cmd_serialports.rst +++ b/docs/userguide/cmd_device.rst @@ -9,14 +9,14 @@ See the License for the specific language governing permissions and limitations under the License. -.. _cmd_serialports: +.. _cmd_device: -platformio serialports +platformio device ====================== .. contents:: -platformio serialports list +platformio device list --------------------------- Usage @@ -24,7 +24,7 @@ Usage .. code-block:: bash - platformio serialports list [OPTIONS] + platformio device list [OPTIONS] Description @@ -35,7 +35,7 @@ List available `Serial Ports `_ Options ~~~~~~~ -.. program:: platformio serialports list +.. program:: platformio device list .. option:: --json-output @@ -50,7 +50,7 @@ Examples .. code-block:: bash - $ platformio serialports list + $ platformio device list /dev/cu.SLAB_USBtoUART ---------- Hardware ID: USB VID:PID=10c4:ea60 SNR=0001 @@ -66,7 +66,7 @@ Examples .. code-block:: bash - $ platformio serialports list + $ platformio device list COM4 ---------- Hardware ID: USB VID:PID=0451:F432 @@ -78,9 +78,9 @@ Examples Description: Silicon Labs CP210x USB to UART Bridge (COM3) -.. _cmd_serialports_monitor: +.. _cmd_device_monitor: -platformio serialports monitor +platformio device monitor ------------------------------ Usage @@ -88,7 +88,7 @@ Usage .. code-block:: bash - platformio serialports monitor [OPTIONS] + platformio device monitor [OPTIONS] Description @@ -112,7 +112,7 @@ To control *monitor* please use these "hot keys": Options ~~~~~~~ -.. program:: platformio serialports monitor +.. program:: platformio device monitor .. option:: -p, --port @@ -194,7 +194,7 @@ ASCII code of special character that is used to exit the application, default ``29`` (DEC). For example, to use ``Ctrl+Q`` run -``platformio serialports monitor --exit-char 17``. +``platformio device monitor --exit-char 17``. .. option:: --menu-char @@ -238,8 +238,8 @@ multiple times: 3. hex dump everything **REMOVED**: Is not available in Miniterm/PySerial 3.0. -See :option:`platformio serialports monitor --encoding` and -:option:`platformio serialports monitor --filter` options. +See :option:`platformio device monitor --encoding` and +:option:`platformio device monitor --filter` options. Examples ~~~~~~~~ @@ -248,8 +248,8 @@ Examples .. code-block:: bash - $ platformio serialports monitor --help - Usage: platformio serialports monitor [OPTIONS] + $ platformio device monitor --help + Usage: platformio device monitor [OPTIONS] Options: -p, --port TEXT Port, a number or a device name @@ -276,7 +276,7 @@ Examples .. code-block:: bash - $ platformio serialports monitor + $ platformio device monitor --- Available ports: --- /dev/cu.Bluetooth-Incoming-Port n/a diff --git a/docs/userguide/cmd_run.rst b/docs/userguide/cmd_run.rst index c5b75ea3..b785a7a5 100644 --- a/docs/userguide/cmd_run.rst +++ b/docs/userguide/cmd_run.rst @@ -64,7 +64,7 @@ Pre-built targets: --upload-port Upload port of embedded board. To print all available ports use -:ref:`cmd_serialports` command. +:ref:`cmd_device` command. If upload port is not specified, PlatformIO will try to detect it automatically. diff --git a/docs/userguide/cmd_test.rst b/docs/userguide/cmd_test.rst index 7c74361d..e34ea0c0 100644 --- a/docs/userguide/cmd_test.rst +++ b/docs/userguide/cmd_test.rst @@ -76,7 +76,7 @@ For example, ``platformio test --ignore "mytest*" -i "test[13]"`` --upload-port Upload port of embedded board. To print all available ports use -:ref:`cmd_serialports` command. +:ref:`cmd_device` command. If upload port is not specified, PlatformIO will try to detect it automatically. diff --git a/docs/userguide/index.rst b/docs/userguide/index.rst index d6a49049..2a3b0f2a 100644 --- a/docs/userguide/index.rst +++ b/docs/userguide/index.rst @@ -60,10 +60,10 @@ Commands cmd_boards cmd_ci + cmd_device cmd_init platformio platform cmd_run - cmd_serialports cmd_settings cmd_test cmd_update diff --git a/platformio/__main__.py b/platformio/__main__.py index 08679523..5ee08cb9 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -52,8 +52,11 @@ class PlatformioCLI(click.MultiCommand): # pylint: disable=R0904 @staticmethod def _handle_obsolate_command(name): if name == "platforms": - from platformio.commands import platform - return platform.cli + from platformio.commands.platform import cli + return cli + elif name == "serialports": + from platformio.commands.device import cli + return cli raise AttributeError() diff --git a/platformio/commands/serialports.py b/platformio/commands/device.py similarity index 95% rename from platformio/commands/serialports.py rename to platformio/commands/device.py index a42e59f6..e423f273 100644 --- a/platformio/commands/serialports.py +++ b/platformio/commands/device.py @@ -24,14 +24,14 @@ from platformio.exception import MinitermException from platformio.util import get_serialports -@click.group(short_help="List or Monitor Serial ports") +@click.group(short_help="Monitor device or list existing") def cli(): pass -@cli.command("list", short_help="List Serial ports") +@cli.command("list", short_help="List devices") @click.option("--json-output", is_flag=True) -def serialports_list(json_output): +def device_list(json_output): if json_output: click.echo(json.dumps(get_serialports())) @@ -47,7 +47,7 @@ def serialports_list(json_output): if int(PYSERIAL_VERSION[0]) == 3: - @cli.command("monitor", short_help="Monitor Serial port") + @cli.command("monitor", short_help="Monitor device (Serial)") @click.option("--port", "-p", help="Port, a number or a device name") @click.option( "--baud", @@ -112,7 +112,7 @@ if int(PYSERIAL_VERSION[0]) == 3: "--quiet", is_flag=True, help="Diagnostics: suppress non-error messages, default=Off") - def serialports_monitor(**kwargs): + def device_monitor(**kwargs): if not kwargs['port']: for item in get_serialports(): if "VID:PID" in item['hwid']: @@ -143,7 +143,7 @@ if int(PYSERIAL_VERSION[0]) == 3: raise MinitermException(e) else: - @cli.command("monitor", short_help="Monitor Serial port") + @cli.command("monitor", short_help="Monitor device (Serial)") @click.option("--port", "-p", help="Port, a number or a device name") @click.option( "--baud", @@ -210,7 +210,7 @@ else: "--quiet", is_flag=True, help="Diagnostics: suppress non-error messages, default=Off") - def serialports_monitor(**kwargs): + def device_monitor(**kwargs): sys.argv = app.get_session_var("command_ctx").args[1:] if not kwargs['port']: diff --git a/platformio/commands/init.py b/platformio/commands/init.py index 2f6482b2..943cd9cb 100644 --- a/platformio/commands/init.py +++ b/platformio/commands/init.py @@ -42,7 +42,8 @@ def validate_boards(ctx, param, value): # pylint: disable=W0613 ", ".join(unknown_boards)) -@click.command("init", short_help="Initialize new PlatformIO based project") +@click.command( + "init", short_help="Initialize PlatformIO project or update existing") @click.option( "--project-dir", "-d", diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 23ff4483..533ce50c 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -27,6 +27,7 @@ from platformio.downloader import FileDownloader from platformio.unpacker import FileUnpacker from platformio.vcsclient import VCSClientFactory + # pylint: disable=too-many-arguments diff --git a/tests/conftest.py b/tests/conftest.py index a6cf052d..f5277a3e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,8 +15,11 @@ import os import pytest +import requests from click.testing import CliRunner +requests.packages.urllib3.disable_warnings() + @pytest.fixture(scope="session") def platformio_setup(request): @@ -40,10 +43,12 @@ def clirunner(): @pytest.fixture(scope="session") def validate_cliresult(): + def decorator(result): assert result.exit_code == 0 assert not result.exception assert "error" not in result.output.lower() + return decorator