Skip to content

Commit fb5b849

Browse files
committed
fix: only root help uses the saved file
1 parent 6c09bbb commit fb5b849

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/bootstrap/bootstrap.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,8 +1375,8 @@ def main():
13751375
args = parse_args(sys.argv)
13761376
help_triggered = args.help or len(sys.argv) == 1
13771377

1378-
# If the user is asking for help, it prints commands from the saved file.
1379-
if help_triggered:
1378+
# Root help (e.g., x.py --help) prints help from the saved file to save the time
1379+
if help_triggered and sys.argv[1] in ["-h", "--help"]:
13801380
try:
13811381
with open(
13821382
os.path.join(os.path.dirname(__file__), "../etc/xhelp"), "r"
@@ -1385,10 +1385,21 @@ def main():
13851385
print(f.read(), end="")
13861386
sys.exit(0)
13871387
except Exception as error:
1388-
eprint(f"ERROR: unable to run help: {error}")
1389-
eprint("x.py run generate-help may solve the problem.")
1388+
eprint(
1389+
f"ERROR: unable to run help: {error}\n",
1390+
"x.py run generate-help may solve the problem.",
1391+
)
13901392
sys.exit(1)
13911393

1394+
1395+
# If the user is asking for other helps, let them know that the whole download-and-build
1396+
# process has to happen before anything is printed out.
1397+
if help_triggered:
1398+
eprint(
1399+
"INFO: Downloading and building bootstrap before processing --help command.\n",
1400+
"See src/bootstrap/README.md for help with common commands.",
1401+
)
1402+
13921403
exit_code = 0
13931404
success_word = "successfully"
13941405
try:
@@ -1401,12 +1412,13 @@ def main():
14011412
eprint(error)
14021413
success_word = "unsuccessfully"
14031414

1404-
eprint(
1405-
"Build completed",
1406-
success_word,
1407-
"in",
1408-
format_build_time(time() - start_time),
1409-
)
1415+
if not help_triggered:
1416+
eprint(
1417+
"Build completed",
1418+
success_word,
1419+
"in",
1420+
format_build_time(time() - start_time),
1421+
)
14101422

14111423
sys.exit(exit_code)
14121424

0 commit comments

Comments
 (0)