mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
List available project targets with a new "platformio run –list-targets" command // Resolve #3544
This commit is contained in:
@ -23,6 +23,7 @@ PlatformIO Core 4
|
|||||||
- 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)
|
||||||
|
|
||||||
|
|
||||||
|
* 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
|
||||||
* 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>`_)
|
||||||
|
2
docs
2
docs
Submodule docs updated: 53c8b74e70...e2ed400698
@ -12,9 +12,9 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import operator
|
||||||
|
import os
|
||||||
from multiprocessing import cpu_count
|
from multiprocessing import cpu_count
|
||||||
from os import getcwd
|
|
||||||
from os.path import isfile
|
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@ -26,7 +26,7 @@ from platformio.commands.run.helpers import clean_build_dir, handle_legacy_libde
|
|||||||
from platformio.commands.run.processor import EnvironmentProcessor
|
from platformio.commands.run.processor import EnvironmentProcessor
|
||||||
from platformio.commands.test.processor import CTX_META_TEST_IS_RUNNING
|
from platformio.commands.test.processor import CTX_META_TEST_IS_RUNNING
|
||||||
from platformio.project.config import ProjectConfig
|
from platformio.project.config import ProjectConfig
|
||||||
from platformio.project.helpers import find_project_dir_above
|
from platformio.project.helpers import find_project_dir_above, load_project_ide_data
|
||||||
|
|
||||||
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches
|
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ except NotImplementedError:
|
|||||||
@click.option(
|
@click.option(
|
||||||
"-d",
|
"-d",
|
||||||
"--project-dir",
|
"--project-dir",
|
||||||
default=getcwd,
|
default=os.getcwd,
|
||||||
type=click.Path(
|
type=click.Path(
|
||||||
exists=True, file_okay=True, dir_okay=True, writable=True, resolve_path=True
|
exists=True, file_okay=True, dir_okay=True, writable=True, resolve_path=True
|
||||||
),
|
),
|
||||||
@ -68,6 +68,7 @@ except NotImplementedError:
|
|||||||
@click.option("-s", "--silent", is_flag=True)
|
@click.option("-s", "--silent", is_flag=True)
|
||||||
@click.option("-v", "--verbose", is_flag=True)
|
@click.option("-v", "--verbose", is_flag=True)
|
||||||
@click.option("--disable-auto-clean", is_flag=True)
|
@click.option("--disable-auto-clean", is_flag=True)
|
||||||
|
@click.option("--list-targets", is_flag=True)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(
|
def cli(
|
||||||
ctx,
|
ctx,
|
||||||
@ -80,11 +81,12 @@ def cli(
|
|||||||
silent,
|
silent,
|
||||||
verbose,
|
verbose,
|
||||||
disable_auto_clean,
|
disable_auto_clean,
|
||||||
|
list_targets,
|
||||||
):
|
):
|
||||||
app.set_session_var("custom_project_conf", project_conf)
|
app.set_session_var("custom_project_conf", project_conf)
|
||||||
|
|
||||||
# find project directory on upper level
|
# find project directory on upper level
|
||||||
if isfile(project_dir):
|
if os.path.isfile(project_dir):
|
||||||
project_dir = find_project_dir_above(project_dir)
|
project_dir = find_project_dir_above(project_dir)
|
||||||
|
|
||||||
is_test_running = CTX_META_TEST_IS_RUNNING in ctx.meta
|
is_test_running = CTX_META_TEST_IS_RUNNING in ctx.meta
|
||||||
@ -93,6 +95,9 @@ def cli(
|
|||||||
config = ProjectConfig.get_instance(project_conf)
|
config = ProjectConfig.get_instance(project_conf)
|
||||||
config.validate(environment)
|
config.validate(environment)
|
||||||
|
|
||||||
|
if list_targets:
|
||||||
|
return print_target_list(list(environment) or config.envs())
|
||||||
|
|
||||||
# clean obsolete build dir
|
# clean obsolete build dir
|
||||||
if not disable_auto_clean:
|
if not disable_auto_clean:
|
||||||
build_dir = config.get_optional_dir("build")
|
build_dir = config.get_optional_dir("build")
|
||||||
@ -261,3 +266,33 @@ def print_processing_summary(results):
|
|||||||
is_error=failed_nums,
|
is_error=failed_nums,
|
||||||
fg="red" if failed_nums else "green",
|
fg="red" if failed_nums else "green",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def print_target_list(envs):
|
||||||
|
tabular_data = []
|
||||||
|
for env, data in load_project_ide_data(os.getcwd(), envs).items():
|
||||||
|
tabular_data.extend(
|
||||||
|
sorted(
|
||||||
|
[
|
||||||
|
(
|
||||||
|
click.style(env, fg="cyan"),
|
||||||
|
t["group"],
|
||||||
|
click.style(t.get("name"), fg="yellow"),
|
||||||
|
t["title"],
|
||||||
|
t.get("description"),
|
||||||
|
)
|
||||||
|
for t in data.get("targets", [])
|
||||||
|
],
|
||||||
|
key=operator.itemgetter(1, 2),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
tabular_data.append((None, None, None, None, None))
|
||||||
|
click.echo(
|
||||||
|
tabulate(
|
||||||
|
tabular_data,
|
||||||
|
headers=[
|
||||||
|
click.style(s, bold=True)
|
||||||
|
for s in ("Environment", "Group", "Name", "Title", "Description")
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
Reference in New Issue
Block a user