Skip to content

the goal of this kata is to learn to work incrementally by implementing a cli arguments parser.

License

Notifications You must be signed in to change notification settings

ivoputzer/cli-args-parser-kata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

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

  • 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 😉

Specification

Choose one of the following input formats:

  • string like arguments "--foo bar"
  • array like arguments ["--foo", "bar"]

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

About

the goal of this kata is to learn to work incrementally by implementing a cli arguments parser.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published