Skip to content

Feat/cli config non interactive - #661

Merged
shiliu-yang merged 2 commits into
masterfrom
feat/cli-config-non-interactive
Aug 5, 2026
Merged

Feat/cli config non interactive#661
shiliu-yang merged 2 commits into
masterfrom
feat/cli-config-non-interactive

Conversation

@shiliu-yang

Copy link
Copy Markdown
Contributor

PR 描述/PR description

[在此详细描述 PR 的内容]/[Describe the PR content in detail here]

代码质量/Code Quality:

在本次拉取请求中,我已考虑以下事项 As part of this pull request, I've considered the following:

  • 确保代码注释和文档清晰,并使用英文注释以保证代码可读性。Ensure that the code comments and documentation are clear, and use English for comments to ensure code readability.
  • 确保文件头遵循文件头格式。Ensure that the file header follows the File Header Format.
  • 确保函数头遵循 Doxygen 格式。Ensure that function headers follow the Doxygen format as specified in Comments.
  • 已查阅 编码风格指南,并核查代码风格合规性,包括缩进、空格、命名规范及其他风格要求。 Reviewed the Coding Style Guide and verified code style compliance, including indentation, spacing, naming conventions, and other style guidelines.
  • 已使用代码格式化工具确保符合 TuyaOpen 编码规范。Have used the code-formatting source code formatting tool to ensure compliance with TuyaOpen coding standards.

do_subprocess() built commands as "cd <dir> && <cmd>" and ran them
through os.system. On Windows that goes to `cmd.exe /c`, whose `cd`
does not switch drives without /d, so a cross-drive prepare/build step
silently ran in the original directory. Unquoted directories with
spaces broke the same way on every platform.

do_subprocess() now takes an optional cwd and uses subprocess.call, so
the directory is handed to the process and never parsed by the shell.
Updated the call sites that prefixed `cd`: platform prepare, build
setup, cmake configure, ninja build, ninja clean, and submodule
download.

KeyboardInterrupt is intentionally left uncaught so Ctrl-C aborts the
whole command rather than being reported as a build failure.

Adds tools/cli_command/tests/test_util_subprocess.py covering cwd
handling, exit-code propagation, and the Ctrl-C path.
Configuring a build without a TTY meant hand-editing app_default.config,
which bypasses kconfiglib: `choice` symbols are not made mutually
exclusive, derived symbols (CONFIG_PLATFORM_CHOICE, CONFIG_CHIP_CHOICE)
are not updated, and the generated using.cmake / tuya_kconfig.h stay
stale on a warm build tree because tools/kconfiglib/CMakeLists.txt only
generates them when absent.

New subcommands, all driving the real Kconfig tree (CONFIG_ prefix
optional everywhere):

  config set NAME=VALUE ...   dependency-aware assignment, -u to revert
                              a symbol to its Kconfig default
  config get NAME ...         value, or -a for type/prompt/deps
  config list [-p PATTERN]    effective config, substring or glob filter
  config diff A [B]           compare two configs, expanded through
                              Kconfig so equivalent minimal files match
  config save -n NAME [-f]    save without prompting

`config set` parses every token before touching state and exits
non-zero writing nothing if any assignment fails, so a batch is
all-or-nothing. After a successful write it re-derives using.config
from app_default.config and invalidates the derived build artifacts.
Changing platform/board identity triggers the full clean that switch
requires; --no-save is rejected in that case because the clean would
discard the change.

`config save` now guards against overwriting an existing file (-f to
override) and fails with a clear message instead of hanging when stdin
is not a TTY. The overwrite guard is scoped to -n so the interactive
flow is unchanged.

Adds tools/cli_command/util_kconfig.py with the kconfiglib helpers, unit
tests for it and for cli_config, and an opt-in end-to-end suite that
loads the real Kconfig tree (TUYAOPEN_E2E=1, no compilation). Documents
both in AGENTS.md.
@shiliu-yang
shiliu-yang merged commit 2d6b4a9 into master Aug 5, 2026
2 checks passed
@shiliu-yang
shiliu-yang deleted the feat/cli-config-non-interactive branch August 5, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants