Move "pio exec" command to "pio pkg exec" // Issue #4163

This commit is contained in:
Ivan Kravets
2022-02-12 23:13:17 +02:00
parent 0bdef36e2a
commit 89cce21161
4 changed files with 9 additions and 6 deletions

View File

@ -16,8 +16,7 @@ PlatformIO Core 5
- New unified Package Management CLI (``pio pkg``):
* `pio pkg outdated <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_pack.html>`__ - check for project outdated packages
- Run command from a PlatformIO package with a new `pio exec <https://docs.platformio.org/en/latest/core/userguide/cmd_exec.html>`__ (`issue #4163 <https://github.com/platformio/platformio-core/issues/4163>`_)
* `pio pkg exec <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_exec.html>`_ - run command from package tool (`issue #4163 <https://github.com/platformio/platformio-core/issues/4163>`_)
* Improved PIO Remote setup on credit-card sized computers (Raspberry Pi, BeagleBon, etc) (`issue #3865 <https://github.com/platformio/platformio-core/issues/3865>`_)

2
docs

Submodule docs updated: b2112cd3a4...3a572b1bc3

View File

@ -14,6 +14,7 @@
import click
from platformio.package.commands.exec import package_exec_cmd
from platformio.package.commands.outdated import package_outdated_cmd
from platformio.package.commands.pack import package_pack_cmd
from platformio.package.commands.publish import package_publish_cmd
@ -23,6 +24,7 @@ from platformio.package.commands.unpublish import package_unpublish_cmd
@click.group(
"pkg",
commands=[
package_exec_cmd,
package_outdated_cmd,
package_pack_cmd,
package_publish_cmd,

View File

@ -20,13 +20,14 @@ import click
from platformio.compat import IS_MACOS, IS_WINDOWS
from platformio.exception import UserSideException
from platformio.package.manager.tool import ToolPackageManager
from platformio.proc import get_pythonexe_path
@click.command("exec", short_help="Run command from package")
@click.command("exec", short_help="Run command from package tool")
@click.option("-p", "--package", metavar="<pkg>[@<version>]")
@click.option("-c", "--call", metavar="<cmd> [args...]")
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
def cli(package, call, args):
def package_exec_cmd(package, call, args):
if not call and not args:
raise click.BadArgumentUsage("Please provide command name")
pkg = None
@ -47,8 +48,9 @@ def cli(package, call, args):
"Using %s package"
% click.style("%s@%s" % (pkg.metadata.name, pkg.metadata.version), fg="green")
)
inject_pkg_to_environ(pkg)
inject_pkg_to_environ(pkg)
os.environ["PIO_PYTHON_EXE"] = get_pythonexe_path()
try:
subprocess.run( # pylint: disable=subprocess-run-check
call or args, shell=call is not None, env=os.environ