Dump data intended for IDE extensions/plugins using a new platformio project idedata command

This commit is contained in:
Ivan Kravets
2020-07-15 14:20:29 +03:00
parent 1368fa4c3b
commit a6f143d1ca
3 changed files with 46 additions and 7 deletions

View File

@@ -24,10 +24,11 @@ PlatformIO Core 4
- Launch command with custom options declared in `"platformio.ini" <https://docs.platformio.org/page/projectconf.html>`__ - Launch command with custom options declared in `"platformio.ini" <https://docs.platformio.org/page/projectconf.html>`__
- Python callback as a target (use the power of Python interpreter and PlatformIO Build API) - Python callback as a target (use the power of Python interpreter and PlatformIO Build API)
* Display system-wide information using `platformio system info <https://docs.platformio.org/page/core/userguide/system/cmd_info.html>`__ command (`issue #3521 <https://github.com/platformio/platformio-core/issues/3521>`_) * Display system-wide information using a new `platformio system info <https://docs.platformio.org/page/core/userguide/system/cmd_info.html>`__ command (`issue #3521 <https://github.com/platformio/platformio-core/issues/3521>`_)
* List available project targets (including dev-platform specific and custom targets) with a new `platformio run --list-targets <https://docs.platformio.org/page/core/userguide/cmd_run.html#cmdoption-platformio-run-list-targets>`__ command (`issue #3544 <https://github.com/platformio/platformio-core/issues/3544>`_) * List available project targets (including dev-platform specific and custom targets) with a new `platformio run --list-targets <https://docs.platformio.org/page/core/userguide/cmd_run.html#cmdoption-platformio-run-list-targets>`__ command (`issue #3544 <https://github.com/platformio/platformio-core/issues/3544>`_)
* Added support for "globstar/`**`" (recursive) pattern for the different commands and configuration options (`platformio ci <https://docs.platformio.org/page/core/userguide/cmd_ci.html>`__, `src_filter <https://docs.platformio.org/page/projectconf/section_env_build.html#src-filter>`__, `check_patterns <https://docs.platformio.org/page/projectconf/section_env_check.html#check-patterns>`__, `library.json > srcFilter <https://docs.platformio.org/page/librarymanager/config.html#srcfilter>`__). Python 3.5+ is required. * Added support for "globstar/`**`" (recursive) pattern for the different commands and configuration options (`platformio ci <https://docs.platformio.org/page/core/userguide/cmd_ci.html>`__, `src_filter <https://docs.platformio.org/page/projectconf/section_env_build.html#src-filter>`__, `check_patterns <https://docs.platformio.org/page/projectconf/section_env_check.html#check-patterns>`__, `library.json > srcFilter <https://docs.platformio.org/page/librarymanager/config.html#srcfilter>`__). Python 3.5+ is required.
* Added a new ``-e, --environment`` option to `platformio project init <https://docs.platformio.org/page/core/userguide/project/cmd_init.html#cmdoption-platformio-project-init-e>`__ command that helps to update a PlatformIO project using existing environment * Added a new ``-e, --environment`` option to `platformio project init <https://docs.platformio.org/page/core/userguide/project/cmd_init.html#cmdoption-platformio-project-init-e>`__ command that helps to update a PlatformIO project using existing environment
* Dump data intended for IDE extensions/plugins using a new `platformio project idedata <https://docs.platformio.org/page/core/userguide/project/cmd_idedata.html>`__ command
* Do not generate ".travis.yml" for a new project, let the user have a choice * Do not generate ".travis.yml" for a new project, let the user have a choice
* Fixed an issue with PIO Unit Testing when running multiple environments (`issue #3523 <https://github.com/platformio/platformio-core/issues/3523>`_) * Fixed an issue with PIO Unit Testing when running multiple environments (`issue #3523 <https://github.com/platformio/platformio-core/issues/3523>`_)
* Fixed an issue with improper processing of source files added via multiple Build Middlewares (`issue #3531 <https://github.com/platformio/platformio-core/issues/3531>`_) * Fixed an issue with improper processing of source files added via multiple Build Middlewares (`issue #3531 <https://github.com/platformio/platformio-core/issues/3531>`_)

2
docs

Submodule docs updated: 8ea9872406...0da1c2810b

View File

@@ -14,6 +14,7 @@
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches,line-too-long # pylint: disable=too-many-arguments,too-many-locals,too-many-branches,line-too-long
import json
import os import os
import click import click
@@ -25,7 +26,7 @@ from platformio.ide.projectgenerator import ProjectGenerator
from platformio.managers.platform import PlatformManager from platformio.managers.platform import PlatformManager
from platformio.project.config import ProjectConfig from platformio.project.config import ProjectConfig
from platformio.project.exception import NotPlatformIOProjectError from platformio.project.exception import NotPlatformIOProjectError
from platformio.project.helpers import is_platformio_project from platformio.project.helpers import is_platformio_project, load_project_ide_data
@click.group(short_help="Project Manager") @click.group(short_help="Project Manager")
@@ -38,9 +39,7 @@ def cli():
"-d", "-d",
"--project-dir", "--project-dir",
default=os.getcwd, default=os.getcwd,
type=click.Path( type=click.Path(exists=True, file_okay=False, dir_okay=True, resolve_path=True),
exists=True, file_okay=True, dir_okay=True, writable=True, resolve_path=True
),
) )
@click.option("--json-output", is_flag=True) @click.option("--json-output", is_flag=True)
def project_config(project_dir, json_output): def project_config(project_dir, json_output):
@@ -54,7 +53,6 @@ def project_config(project_dir, json_output):
"Computed project configuration for %s" % click.style(project_dir, fg="cyan") "Computed project configuration for %s" % click.style(project_dir, fg="cyan")
) )
for section, options in config.as_tuple(): for section, options in config.as_tuple():
click.echo()
click.secho(section, fg="cyan") click.secho(section, fg="cyan")
click.echo("-" * len(section)) click.echo("-" * len(section))
click.echo( click.echo(
@@ -66,6 +64,46 @@ def project_config(project_dir, json_output):
tablefmt="plain", tablefmt="plain",
) )
) )
click.echo()
return None
@cli.command("idedata", short_help="Dump data intended for IDE extensions/plugins")
@click.option(
"-d",
"--project-dir",
default=os.getcwd,
type=click.Path(exists=True, file_okay=False, dir_okay=True, resolve_path=True),
)
@click.option("-e", "--environment", multiple=True)
@click.option("--json-output", is_flag=True)
def project_idedata(project_dir, environment, json_output):
if not is_platformio_project(project_dir):
raise NotPlatformIOProjectError(project_dir)
with fs.cd(project_dir):
config = ProjectConfig.get_instance()
config.validate(environment)
environment = list(environment or config.envs())
if json_output:
return click.echo(json.dumps(load_project_ide_data(project_dir, environment)))
for envname in environment:
click.echo("Environment: " + click.style(envname, fg="cyan", bold=True))
click.echo("=" * (13 + len(envname)))
click.echo(
tabulate(
[
(click.style(name, bold=True), "=", json.dumps(value, indent=2))
for name, value in load_project_ide_data(
project_dir, envname
).items()
],
tablefmt="plain",
)
)
click.echo()
return None return None