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)
Tue, Dec 17, 1:43 AM
Unknown Object (File)
Tue, Dec 17, 12:59 AM
Unknown Object (File)
Tue, Dec 17, 12:43 AM
Unknown Object (File)
Sun, Dec 15, 3:20 AM
Unknown Object (File)
Wed, Dec 11, 4:40 PM
Unknown Object (File)
Sun, Dec 8, 11:43 PM
Unknown Object (File)
Sun, Dec 8, 11:43 PM
Unknown Object (File)
Sun, Dec 8, 11:43 PM
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
Branch
console1
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 13144
Build 16819: Run Core Tests
Build 16818: arc lint + arc unit

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".)
...