Home

Awesome

cli-args-parser-kata

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.

Before you start

Specification

Choose one of the following input formats:

1. parse a simple flags

given the following input:

--foo

the program should produce either a dictionary or a JSON object as follows:

{"foo": true}

2. parse a composite flags

given the following input:

--foo bar

the program should produce either a dictionary or a JSON object as follows:

{"foo": "bar"}

3. parse a composite flags with integer values

given the following input:

--number 1

the program should produce either a dictionary or a JSON object as follows:

{"number": 1}

4. parse multiple flags at once

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}

5. try to support both string and array input formats

within the same function or a new function one of your choice.

Submitted solutions