Display system-wide information using platformio system info command // Resolve #3521

This commit is contained in:
Ivan Kravets
2020-06-22 23:04:36 +03:00
parent 3aae791bee
commit 5ee90f4e61
3 changed files with 49 additions and 3 deletions

View File

@ -23,6 +23,7 @@ PlatformIO Core 4
- 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>`_)
* 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 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

2
docs

Submodule docs updated: 478d089d27...f33f42cc9c

View File

@ -12,17 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import platform
import subprocess
import sys
import click
from tabulate import tabulate
from platformio import proc
from platformio import __version__, proc, util
from platformio.commands.system.completion import (
get_completion_install_path,
install_completion_code,
uninstall_completion_code,
)
from platformio.managers.lib import LibraryManager
from platformio.managers.package import PackageManager
from platformio.managers.platform import PlatformManager
from platformio.project.config import ProjectConfig
@click.group("system", short_help="Miscellaneous system commands")
@ -30,6 +37,44 @@ def cli():
pass
@cli.command("info", short_help="Display system-wide information")
@click.option("--json-output", is_flag=True)
def system_info(json_output):
project_config = ProjectConfig()
data = {}
data["core_version"] = {"title": "PlatformIO Core", "value": __version__}
data["python_version"] = {
"title": "Python",
"value": "{0}.{1}.{2}-{3}.{4}".format(*list(sys.version_info)),
}
data["system"] = {"title": "System Type", "value": util.get_systype()}
data["platform"] = {"title": "Platform", "value": platform.platform(terse=True)}
data["core_dir"] = {
"title": "PlatformIO Core Directory",
"value": project_config.get_optional_dir("core"),
}
data["global_lib_nums"] = {
"title": "Global Libraries",
"value": len(LibraryManager().get_installed()),
}
data["dev_platform_nums"] = {
"title": "Development Platforms",
"value": len(PlatformManager().get_installed()),
}
data["package_tool_nums"] = {
"title": "Package Tools",
"value": len(
PackageManager(project_config.get_optional_dir("packages")).get_installed()
),
}
click.echo(
json.dumps(data)
if json_output
else tabulate([(item["title"], item["value"]) for item in data.values()])
)
@cli.group("completion", short_help="Shell completion support")
def completion():
# pylint: disable=import-error,import-outside-toplevel