The following is a TDD Kata: an exercise in coding, refactoring and test-first.
The goal of this program is to model a cli arguments parser. Given a series of input the program should produce a valid output according to the following specification.
- Try not to read ahead, do one task at a time (the trick is to learn to work incrementally)!
- Make sure you only test for correct inputs;
- You may use whatever programming language you prefer;
- You should commit your code on GitHub or any other SCM repository you prefer;
- You should release your work under an OSI-approved open-source license of your choice;
- Remember to send a PR once you're done with the kata 😉
Choose one of the following input formats:
- string like arguments
"--foo bar"
- array like arguments
["--foo", "bar"]
given the following input:
--foo
the program should produce either a dictionary or a JSON object as follows:
{"foo": true}
given the following input:
--foo bar
the program should produce either a dictionary or a JSON object as follows:
{"foo": "bar"}
given the following input:
--number 1
the program should produce either a dictionary or a JSON object as follows:
{"number": 1}
given the following input:
--foo --bar baz --number 1
the program should produce either a dictionary or a JSON object as follows:
{"bar": "baz", "foo": true, "number": 1}
within the same function or a new function one of your choice.