diff options
| author | MoonEyes <ducoinbenjamin@yahoo.fr> | 2026-11-28 20:33:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-28 20:33:27 +0100 |
| commit | ec21061648af106e94411411de9a628b71f7d27f (patch) | |
| tree | 332db0974a8a0da86a5d5b25a94ef955b14de238 /scripts/dev.py | |
| parent | ea49f91cdd0f638c731679b8631cce92b0e55c69 (diff) | |
| parent | 0da952685f9466423a319d5201b9ffe17d646d6b (diff) | |
Merge pull request #2278 from kirigayakazima/fix/dev-cli-safety
dev: accept argv, guard stdout.reconfigure, and reject whitespace --out
Diffstat (limited to 'scripts/dev.py')
| -rw-r--r-- | scripts/dev.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/dev.py b/scripts/dev.py index 4170aac63..00bf1bb21 100644 --- a/scripts/dev.py +++ b/scripts/dev.py | |||
| @@ -90,15 +90,15 @@ def guest_scene(args: list[str]) -> int: | |||
| 90 | parser.add_argument("-h", "--help", action="store_true") | 90 | parser.add_argument("-h", "--help", action="store_true") |
| 91 | parser.add_argument("--out", metavar="PATH") | 91 | parser.add_argument("--out", metavar="PATH") |
| 92 | options, _ = parser.parse_known_args(args) | 92 | options, _ = parser.parse_known_args(args) |
| 93 | if not options.help and not options.out: | 93 | if not options.help and not (options.out and options.out.strip()): |
| 94 | parser.error("--out PATH is required to keep the scene results") | 94 | parser.error("--out PATH is required to keep the scene results") |
| 95 | 95 | ||
| 96 | return run_producer(GUEST_SCENE, args) | 96 | return run_producer(GUEST_SCENE, args) |
| 97 | 97 | ||
| 98 | 98 | ||
| 99 | def main() -> int: | 99 | def main(argv: list[str] | None = None) -> int: |
| 100 | # The producer owns its arguments and help. Forward before argparse handles them. | 100 | # The producer owns its arguments and help. Forward before argparse handles them. |
| 101 | argv = sys.argv[1:] | 101 | argv = sys.argv[1:] if argv is None else list(argv) |
| 102 | if argv[:1] == ["boot-trace"]: | 102 | if argv[:1] == ["boot-trace"]: |
| 103 | return run_producer(BOOT_TRACE, argv[1:]) | 103 | return run_producer(BOOT_TRACE, argv[1:]) |
| 104 | if argv[:1] == ["guest-scene"]: | 104 | if argv[:1] == ["guest-scene"]: |
| @@ -119,7 +119,10 @@ def main() -> int: | |||
| 119 | if args.json: | 119 | if args.json: |
| 120 | print(json.dumps(result, indent=2)) | 120 | print(json.dumps(result, indent=2)) |
| 121 | else: | 121 | else: |
| 122 | sys.stdout.reconfigure(encoding="utf-8") | 122 | try: |
| 123 | sys.stdout.reconfigure(encoding="utf-8") | ||
| 124 | except (AttributeError, ValueError, OSError): | ||
| 125 | pass | ||
| 123 | print("Paths and help commands are relative to the Leonida checkout root.") | 126 | print("Paths and help commands are relative to the Leonida checkout root.") |
| 124 | for tool in result["tools"]: | 127 | for tool in result["tools"]: |
| 125 | status = "present" if tool["present"] else "missing" | 128 | status = "present" if tool["present"] else "missing" |