Command-line programs · 13 / 15 Exercise Hard

Validator with exit code

Objective

Command-line programs report whether they went well with their exit code: 0 means success and any other value, error. Create a password validator that uses it. The arguments of each test are passed to the program as if you typed them in the terminal (they appear in the test cases).

Instructions

  • The password is the first argument (if none is given, it is considered empty).
  • Rules: it must have at least 8 characters, include a digit and include an uppercase letter.
  • For each rule that is not met show a line starting with - : It must have at least 8 characters, It must include a digit or It must include an uppercase letter, in that order.
  • If there is any problem, finish with sys.exit(1). Otherwise show Valid password and finish normally (code 0).
Output
Valid password

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise