Provide a basic argument parser for libphutil
Summary:
Provides a basic configurable argument parser and converts the utf8.php script
to use it.
This doesn't have any builtin support for workflow-style commands yet (e.g,
"arc" and "phd"), or default flag packages (--trace, --conduit-uri,
--load-phutil-library) but parsePartial() gives us the tools we need to build
them in a future diff.
This is a bit NIH/wheel-reinventy but the major alternatives aren't very
appealing:
- getopt() - not nearly powerful enough for serious user-facing scripts (can't
generate help or detect invalid arguments, e.g.)
- PEAR Console_Getargs - Unmaintained, PEAR, no support for partial parses,
ugly help, ugly code, no support for conflicts or contexts.
- PEAR Console_CommandLine - This one actually does most of what we want and
isn't completely awful, but: PEAR, defines 28 classes, PEAR, PEAR, PEAR, PEAR.
Supports sub-commands but no partial parses, so we couldn't do stuff like
--load-phutil-library loading new workflows.
In conclusion, PEAR.
Test Plan: Ran unit tests and the "utf8.php" script in various configurations.
Reviewers: davidreuss, btrahan, jungejason, nh
Reviewed By: davidreuss
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1534