Skip to content

Commit

Permalink
Stop earlier when there is not plan.py (do not create .stepup/)
Browse files Browse the repository at this point in the history
  • Loading branch information
tovrstra committed Aug 24, 2024
1 parent 9dff320 commit 110a2dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
15 changes: 11 additions & 4 deletions stepup/core/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ def main():

async def async_main():
args = parse_args()
if Path(args.root).absolute() != Path.cwd():
if args.root.absolute() != Path.cwd():
print("Changing to", args.root)
os.chdir(args.root)
args.root.cd()

# Sanity check before creating a subdirectory
if not args.plan_py.is_file():
raise RuntimeError(f"File {args.plan_py} does not exist.")

# Create dir
dir_stepup = Path(".stepup")
Expand Down Expand Up @@ -207,10 +211,13 @@ async def keyboard(
def parse_args():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser(prog="stepup", description="The StepUp build tool")
parser.add_argument("plan_py", default="plan.py", help="Top-level build script", nargs="?")
parser.add_argument(
"plan_py", type=Path, default=Path("plan.py"), help="Top-level build script", nargs="?"
)
parser.add_argument(
"--root",
default=os.getenv("STEPUP_ROOT", os.getcwd()),
type=Path,
default=Path(os.getenv("STEPUP_ROOT", os.getcwd())),
help="Directory containing top-level plan.py [default=%(default)s]",
)
parser.add_argument(
Expand Down
12 changes: 0 additions & 12 deletions tests/cases/no_plan/expected_stdout.txt
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
ERROR │ The director raised an exception.
────────────────────────────────── Traceback ───────────────────────────────────
Traceback (most recent call last):
File "${PWD}/stepup/core/director.py", line ---, in async_main
await serve(
File "${PWD}/stepup/core/director.py", line ---, in serve
check_plan(path_plan)
File "${PWD}/stepup/core/utils.py", line ---, in check_plan
raise ValueError(f"Is not a file: {path_plan}")
ValueError: Is not a file: plan.py
────────────────────────────────────────────────────────────────────────────────
DIRECTOR │ See you!

0 comments on commit 110a2dc

Please sign in to comment.