diff options
| author | kirigayakazima <46666711+kirigayakazima@users.noreply.github.com> | 2026-11-26 20:16:20 +0800 |
|---|---|---|
| committer | kirigayakazima <46666711+kirigayakazima@users.noreply.github.com> | 2026-11-26 20:16:20 +0800 |
| commit | 0da952685f9466423a319d5201b9ffe17d646d6b (patch) | |
| tree | 41c62eae9155b467a1b8938547c0967997fa1741 /scripts/dev.py | |
| parent | a73a57e1339be072baf5522351c8ec7f1482b56b (diff) | |
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 fada30da4..aaca1dfcd 100644 --- a/scripts/dev.py +++ b/scripts/dev.py | |||
| @@ -81,15 +81,15 @@ def guest_scene(args: list[str]) -> int: | |||
| 81 | parser.add_argument("-h", "--help", action="store_true") | 81 | parser.add_argument("-h", "--help", action="store_true") |
| 82 | parser.add_argument("--out", metavar="PATH") | 82 | parser.add_argument("--out", metavar="PATH") |
| 83 | options, _ = parser.parse_known_args(args) | 83 | options, _ = parser.parse_known_args(args) |
| 84 | if not options.help and not options.out: | 84 | if not options.help and not (options.out and options.out.strip()): |
| 85 | parser.error("--out PATH is required to keep the scene results") | 85 | parser.error("--out PATH is required to keep the scene results") |
| 86 | 86 | ||
| 87 | return run_producer(GUEST_SCENE, args) | 87 | return run_producer(GUEST_SCENE, args) |
| 88 | 88 | ||
| 89 | 89 | ||
| 90 | def main() -> int: | 90 | def main(argv: list[str] | None = None) -> int: |
| 91 | # The producer owns its arguments and help. Forward before argparse handles them. | 91 | # The producer owns its arguments and help. Forward before argparse handles them. |
| 92 | argv = sys.argv[1:] | 92 | argv = sys.argv[1:] if argv is None else list(argv) |
| 93 | if argv[:1] == ["boot-trace"]: | 93 | if argv[:1] == ["boot-trace"]: |
| 94 | return run_producer(BOOT_TRACE, argv[1:]) | 94 | return run_producer(BOOT_TRACE, argv[1:]) |
| 95 | if argv[:1] == ["guest-scene"]: | 95 | if argv[:1] == ["guest-scene"]: |
| @@ -107,7 +107,10 @@ def main() -> int: | |||
| 107 | if args.json: | 107 | if args.json: |
| 108 | print(json.dumps(result, indent=2)) | 108 | print(json.dumps(result, indent=2)) |
| 109 | else: | 109 | else: |
| 110 | sys.stdout.reconfigure(encoding="utf-8") | 110 | try: |
| 111 | sys.stdout.reconfigure(encoding="utf-8") | ||
| 112 | except (AttributeError, ValueError, OSError): | ||
| 113 | pass | ||
| 111 | print("Paths and help commands are relative to the Leonida checkout root.") | 114 | print("Paths and help commands are relative to the Leonida checkout root.") |
| 112 | for tool in result["tools"]: | 115 | for tool in result["tools"]: |
| 113 | status = "present" if tool["present"] else "missing" | 116 | status = "present" if tool["present"] else "missing" |