Rename `platformio serialports command to platformio device`

This commit is contained in:
Ivan Kravets
2016-08-26 14:25:50 +03:00
parent 6e26ce8162
commit c637729eae
12 changed files with 43 additions and 32 deletions

View File

@ -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 <https://github.com/platformio/platformio/issues/542>`_)
* Print human-readable information when processing environments without

View File

@ -55,7 +55,7 @@ Embedded Development. *Easier Than Ever.*
* :ref:`IDE Integration <ide>` 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 <cmd_serialports_monitor>` and
* Built-in :ref:`Serial Port Monitor <cmd_device_monitor>` and
configurable build :ref:`-flags/-options <projectconf_build_flags>`
* Pre-built toolchains, :ref:`frameworks` for the :ref:`platforms`

View File

@ -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`.

View File

@ -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 <http://en.wikipedia.org/wiki/Serial_port>`_
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

View File

@ -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.

View File

@ -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.

View File

@ -60,10 +60,10 @@ Commands
cmd_boards
cmd_ci
cmd_device
cmd_init
platformio platform <platforms/index>
cmd_run
cmd_serialports
cmd_settings
cmd_test
cmd_update

View File

@ -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()

View File

@ -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']:

View File

@ -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",

View File

@ -27,6 +27,7 @@ from platformio.downloader import FileDownloader
from platformio.unpacker import FileUnpacker
from platformio.vcsclient import VCSClientFactory
# pylint: disable=too-many-arguments

View File

@ -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