One useful idea
A command-line interface is the boundary between people and your functions. argparse.ArgumentParser defines named options, converts input types and generates --help. Keep calculations in the functions you already wrote.
main(argv=None) accepts an optional argument list so tests can call it without changing the process arguments. parser.parse_args(argv) uses that list, or the terminal arguments when it is None. Validate the complete request before printing a success report.
The if __name__ == "__main__" guard runs main only when this file is executed, not when imported. raise SystemExit(main()) supplies an exit status. The reference uses parser.error for invalid requests: useful text, status 2 and no success report.
Trace a finished example
python asset_cli.py --project Museum --shot detail --version 12 --frames 29970 --fps 29.97 --root sample-output --date 2026-10-08
# DRY RUN — Asset Intelligence CLI v0.1
# Filename: Museum_detail_v12.mp4
# Duration: 16:40.000
# Planned destination: <absolute root>/Museum/deliveries/2026-10-08/Museum_detail_v12.mp4
# No files created, renamed or overwritten.Options become typed inputs. The naming, duration and path functions validate the whole request. The CLI prints a report only after all three succeed, then returns status 0. It never applies a rename.
The finished implementation is in asset_tools.py and asset_cli.py. Reading it is guided practice, not independent evidence.
Predict before running
Should importing practice_cli immediately print a delivery report?
Compare your answer · self-reviewed
No. The __main__ guard keeps terminal behavior out of imports. Tests import main and call it explicitly with their own argument list.
Find the bug
Why is printing “success” before validating the date misleading?
Compare your answer · self-reviewed
An invalid date could fail after the success message. Validate all inputs first, then print the complete report only for a successful request.
Explain the boundary
Does a successful dry run prove any media files were renamed?
Compare your answer · self-reviewed
No. It proves the preview can be computed for that request. No writes occur, and reading or running the reference is not evidence that your independent implementation works.
Change it, then build your own
One controlled change
Run asset_cli.py --help, then a valid preview, then --fps 0. Compare the success report with the failure text. No directory should be created in either case.
Your independent task
Implement main(argv=None) in practice_cli.py. Import your functions from practice, not asset_tools. Define --project, --shot, --version (int), --frames (int), --fps (float), --root and --date with the reference defaults. Set the parser description to include “Never creates or renames files”. Compute all results before output. Catch validation/path errors and call parser.error(str(error)); on success print the dry-run heading, Filename:, Duration:, Planned destination: (folder / name) and “No files created, renamed or overwritten.”, then return 0. Add the __main__ guard.
What success looks like
Three CLI test methods pass when isolated with --build 4. Then all 16 module test methods pass with --build all, using your practice.py and practice_cli.py. --help must document the options and the no-rename boundary; invalid input must print no partial preview.
Hint 1 · a question
List the seven options and identify which need int or float conversion. Where should user input stop and reusable functions begin?
Hint 2 · a concept cue
Create parser, parse argv, compute name/duration/path in a try block, handle refused input, then print the report. Read asset_cli.py only when you need a more complete worked example.
Hint 3 · a localized example
Return 0 on success. parser.error(...) raises SystemExit with status 2. Use raise SystemExit(main()) only inside the __main__ guard.
Need the complete worked solution?
Open asset_tools.py and asset_cli.py from the kit. Trace it, close it, then try fresh inputs in your own files. Treat the attempt as guided; seeing the solution does not award a practical pass.
Course help is guidance, not independent evidence. With JavaScript, opening help records guidance locally; otherwise note it in your README. Reset does not erase that history.
Repair a failed check
If tests pass only against the reference, check your imports: practice_cli must use practice. If a failed command prints Filename:, move output after validation. If an import starts the command, add the __main__ guard. If argparse rejects a correct option, compare its spelling and type with --help.
NotImplementedError means a practice stub is still unfinished. Read the failing test name and the last error line. Change one behavior, rerun that build, then rerun all implemented builds.
Show it works on new inputs
Without copying the report, run your own CLI for Museum/detail/version 12, 29970 frames at 29.97 fps and date 2026-10-08. Add a new project of your own and one refused input. Save the commands and outputs in your local README, then explain which parts are calculation, validation and presentation.
Self-review: name the input, result, refused case and reason. Your local test output and explanation are separate from a quiz score; this page does not certify a pass.
Keep the idea
You have a tested preview utility, not the complete Asset Intelligence portfolio system. Keep this kit; later modules add classification, inventory and a defensible project review.
Module 1 checkpoint
Five questions, followed by the separate practical task above. JavaScript loads the scored questions; the build, files and hints remain available without it.