Page MenuHomePhabricator

Move command spelling correction to libphutil
ClosedPublic

Authored by epriestley on Jul 27 2016, 12:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 19, 5:07 PM
Unknown Object (File)
Thu, Apr 4, 8:37 PM
Unknown Object (File)
Thu, Apr 4, 8:37 PM
Unknown Object (File)
Thu, Apr 4, 8:37 PM
Unknown Object (File)
Sun, Mar 31, 5:08 AM
Unknown Object (File)
Sat, Mar 30, 2:31 AM
Unknown Object (File)
Mar 20 2024, 7:51 PM
Unknown Object (File)
Feb 10 2024, 9:57 AM
Subscribers

Details

Summary

Ref T7489. Currently, arc has helpful flag/argument spelling correction but libphutil does not.

The implementation in arc is also pretty hard-coded, and exposed as static methods on ArcanistConfiguration. This class isn't closely related to argument parsing, and I would like to remove it anyway (see T10329).

This copies the bulk of the implementation to libphutil and separates it out so it isn't bolted onto some other class.

(arc may still need to do some of this on its own, since it has additional rules like aliases that I don't necessarily expect to generalize, but should be able to share this code.)

Test Plan
$ ./bin/repository reparce --messages
(Assuming "reparce" is the British spelling of "reparse".)
(Assuming "--messages" is the British spelling of "message".)
Usage Exception: Specify a commit or repository to reparse.
$ ./bin/repository heaw
Usage Exception: Invalid command "heaw". Did you mean:
      help
      thaw

For details on available commands, run `repository help`.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Move command spelling correction to libphutil.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
  • Slightly simpler code; let the corrector correct case changes ("DIFF" -> "diff") too.
  • Slightly more consistent "british" feedback for flags: "--x" is the spelling of "--y" (not "y", without "--").
chad edited edge metadata.
This revision is now accepted and ready to land.Jul 27 2016, 3:39 PM
This revision was automatically updated to reflect the committed changes.

Was it intentional that this is no longer case-sensitive? I used this method for a custom linter rule and it no longer detects foobar as a mispelling of FOOBAR.

Sort of -- it intentionally normalizes everything to lowercase now (I think this would previously work, but not warn you about the correction):

$ ./bin/storage STATUS
(Assuming "STATUS" is the British spelling of "status".)
...