Advanced level · Module 6: C++ Capstone Project · Lesson 3 of 5
CLI, Reports and Error Reporting
Build the command-line tool and its reports on top of the library, with helpful usage and error messages.
In this lesson you will
- Implement a CLI with argument parsing and usage help
- Generate clear reports and summaries of errors
Key concepts
argument parsingusage messageexit codesreport format
The lesson
Parse command-line arguments into a configuration struct, validate it and print a usage message for --help or invalid options. Return a non-zero exit code on failure so scripts can detect it.
Write the daily report in a simple, documented format such as CSV, plus a summary of skipped lines and reasons.
Test the CLI end to end with small sample files and compare the output with expected files.
Step by step
- Implement argument parsing and --help.
- Generate the daily report and error summary.
- Return meaningful exit codes.
- Write end-to-end tests with expected outputs.
Practice activity
Complete milestone 3: a working CLI with reports and end-to-end tests.
Expected result: The CLI produces correct reports for the sample data and exits with the documented codes.
Check your understanding
-
Why return a non-zero exit code on failure?
Show answer
So scripts and other programs can detect that the tool failed.
-
What is an end-to-end test here?
Show answer
Running the CLI on a sample file and comparing its output with an expected file.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.