Homec4science

Provide a basic argument parser for libphutil

Authored by epriestley <git@epriestley.com> on Feb 1 2012, 20:44.

Description

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

Details

Committed
epriestley <git@epriestley.com>Feb 1 2012, 20:44
Pushed
aubortMar 17 2017, 12:03
Parents
rPHU69f012ad7174: Remove 'final' from PhutilRemarkupRuleHyperLink
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHUbfc408aa0243: Provide a basic argument parser for libphutil (authored by epriestley <git@epriestley.com>).Feb 1 2012, 20:44