lucapette / fakedata

CLI utility for fake data generation
MIT License
200 stars 7 forks source link

Extract option parsing #48

Closed lucapette closed 7 years ago

lucapette commented 7 years ago

Built on top of #43 and for that reason I'm opening the PR against that branch. So that understanding what I've done in the context of this one is easier to read.

There are a few unrelated changes that create some noise (renaming, some gardening) so let me explain what's the core of this change.

Before this change, fakedata would do the following:

This change affects the algorithm so that we do parsing of the options only once. After the change:

It's a lot of changes but I believe it leads to better design. The two pass-algorithm removes the need for caches (like the fileCache we introduced in the file generator) and opens the door to any optimization we'd like to do in the future (in case it's needed).

I introduced a private factory too, as a consequence of this conversation which removed the init func we have.