Cleanup option parsing #23

Merged
6 commits merged into from Jan 28, 2011

Projects

None yet

1 participant

@jlouis
Contributor
jlouis commented Jan 28, 2011

This patch set cleans up option parsing and makes the agner command output a list of commands it understands. It somewhat makes sense that it is a merge rather than a rebase IMO as it has to take into account that something happened on the main branch.

jlouis added some commits Jan 28, 2011
@jlouis jlouis Split agner:main/1 into its constituents.
The agner:main/1 function actually did several things at once:

* Provided parsing of command-line options
* Provided handling of commands
* Printed out general usage

This change splits the concerns. First, we add a function to parse the
command line options and internalize them. Next, we alter the
command-handlers to match on the parsed variant. The change also
allows us to hoist the start()/stop() invocation to main/1 and only do
that in one place.

Further, the change paves the way for a more consistent option parsing
and argument handling further down the road.
3990fe9
@jlouis jlouis Gather option parsing into the parsing primitives.
Rather than have option parsing spread out over the command handler
function, gather all calls into a single point. This means that all
option parsing is now handled in one place.
2483ee4
@jlouis jlouis Don't use our own tmpfile(3) implementation
Even though the one in the stdlib is not much better.
5a8c30a
@jlouis jlouis Transform the command-line parser into data.
Rather than write code which acts as data, transform the code into
data and write code acting on the data. This paves the way for
outputting the commands in the usage.
3d151ff
@jlouis jlouis Make 'agner' output a useful usage listing.
Reap the benefits of the preceding commits: Output a usage list where
the valid, supported, commands are included. Note that adding a
command to the parser will automatically extend the usage output.
ebbf23e
@jlouis jlouis Merge remote branch 'upstream/master' into cleanup-option-parsing-old
Conflicts:
	src/agner.erl
4b9a49d
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment