Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope subcommand followed by other tokens #23

Merged
merged 44 commits into from
Jul 31, 2023

Commits on Jul 17, 2023

  1. Scope lowercase terms when followed by other terms

    Terms as in "defined terms".
    
    Mostly for subcommands followed by arguments or other subcommands. Which
    are defined terms themselves, but still not handled.
    
    e.g.: "reconnect device         kick connection from device side to ..."
    
    In terms of regression delta, census:
    
    - adb: ok, it motivated this change
    - chown: not ideal, examples with chown itself are scoped. but acceptable.
    - npm: idem.
    - dpkg: not cool, I should limit term sequences to 3-4 terms
    
    Some unhandled cases in adb, chown and npm,
    
    - reveal the single_2_space variable does't work
    - show a need to treat definitions that do \n after the terms
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    3e4ef4a View commit details
    Browse the repository at this point in the history
  2. Fix broken adb syntax test

    I was debugging a problem that didn't exist 😱
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    80382b0 View commit details
    Browse the repository at this point in the history
  3. Add tests showing what's wrong with other-term-seq

    It's like it doesn't properly use all the {{long_space}} cases (newline
    and single_2_space)
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    beae871 View commit details
    Browse the repository at this point in the history
  4. Scope argument after subcommand

    But it's kinda weird because in
    
     forward --remove LOCAL
    
    it scopes the LOCAL but skips the --remove.
    
    I guess this skip happens in the option-def+space context? Anyways,
    worth running the syntest debugger on.
    
    But not today!
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    dd43878 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    db357da View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    83941df View commit details
    Browse the repository at this point in the history
  7. Rename other-def -> keyword, other-variable -> variable

    For ease of use. Other X is less wrong but a little more unwieldy to
    write and reason about.
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    4094410 View commit details
    Browse the repository at this point in the history
  8. Rename "..other.def.." scope to "keyword"

    To reflect the new change in KEYWORD_SCOPES' name
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    1dbc324 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    adc4446 View commit details
    Browse the repository at this point in the history
  10. Scope "subcommand --option"

    But I'm considering leaving the later unscoped, or any other 2nd term
    after a keyword term.
    
    Cause it causes regressions in other, more common commands, where it
    scopes terms in examples. (As in every other delta in this commit)
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    09e84e7 View commit details
    Browse the repository at this point in the history
  11. Scope "keyword [--option]"

    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    32cdd01 View commit details
    Browse the repository at this point in the history
  12. Scope "keyword [ARGUMENT]"

    And it introduces a hell of a regression in the Usage section of a few
    other commands.
    
    This is breaking for me, we'll probably do the 1st keyword only.
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    437fc88 View commit details
    Browse the repository at this point in the history
  13. Scope "keyword ARGUMENT"

    But this introduces quite a bit of regression. See syntax_test_cp
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    ceefab3 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    2157efe View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    9887fbd View commit details
    Browse the repository at this point in the history
  16. Rename scripts/env.sh to ../utils

    The shelcheck directive is explained here:
    https://www.shellcheck.net/wiki/SC2148
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    57748ff View commit details
    Browse the repository at this point in the history
  17. Don't scope the 2nd term after a subcommand

    To avoid inconsistent scoping in the usage/examples section of a bunch
    of help messages.
    
    But keep these scope assignations as comments, for future reference.
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    a064b0f View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    f59e14e View commit details
    Browse the repository at this point in the history
  19. Handle ""pair HOST[:PORT] ..." from adb

    Only the "pair" bit.
    
    This is all so overfitted, to suit adb's help message only, that it's
    making me feel icky.
    
    But, on the other hand, it's also a good census of all kinds of patterns
    that we don't currently have a proper way to handle.
    
    And if it doesn't add too many unnecessary scopes for other help
    messages, I don't care much, I guess?
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    fda6af9 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    e42fe00 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    11071bb View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    938f74b View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    6a70341 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    f8bf10d View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    310a626 View commit details
    Browse the repository at this point in the history
  26. Remove subcommand-def-post

    We're handling subcommand sub-tokens in an explicit manner, without
    abstraction / generalization. At least for the time being.
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    bd64ca0 View commit details
    Browse the repository at this point in the history
  27. Handle "bat <SUBCOMMAND>" from bat

    Now we're scoping command keywords in usage lines so as to make them
    coherent. Otherwise, some help messages show usage lines with and
    without the command colorized.
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    3de9f62 View commit details
    Browse the repository at this point in the history
  28. Separate {{long_space}} and {{single_2_space}}

    I hoped to catch the tricky chown case with this, but I think I know why
    it's failing: we do not `set: then-pop" in keyword-seq-def matches !!
    
    As a side effect, we scoped "operand=VALUE" operands in dd, which is
    nice.
    
    As another side effect, we scoped "or:" usage lines in vim, which is bad
    but easy to fix (next commit).
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    885f8c8 View commit details
    Browse the repository at this point in the history
  29. Don't scope "or:" as keyword other

    Cause it's an alternative connector in Usage lines
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    833cbb9 View commit details
    Browse the repository at this point in the history
  30. Properly set: then-pop after each keyword-seq-def match

    I hoped to catch the chown corner case with this but no such luck.
    
    Instead, we caught a stray adb bug that I had forgotten all about (but
    my syntax tests didn't :D ).
    victor-gp committed Jul 17, 2023
    Configuration menu
    Copy the full SHA
    751858f View commit details
    Browse the repository at this point in the history

Commits on Jul 18, 2023

  1. Scope bat in "Usage: bat"

    To harmonize with the following line, where "bat" is scoped.
    
    This is very hacky but highlighting bat's help message properly is a big
    priority for this syntax, as bat is our only playground.
    
    Also renames the test file, cause it was incorrectly versioned 23.0.0
    victor-gp committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    aa81feb View commit details
    Browse the repository at this point in the history
  2. Handle "mount [options] ..." from mount

    This change also has lots of side-effects.
    
    ghc, ghci and tealdeer are ok
    
    It leaves the jq in the "usage: jq ..." line not scoped, but it's
    acceptable to me. Not like bat's case.
    victor-gp committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    a700040 View commit details
    Browse the repository at this point in the history
  3. Change a todo comment priority

    Cause keyword=VALUE looks pretty ugly if only the former is colorized.
    victor-gp committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    22ceeb2 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    7e46345 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    01e0bbf View commit details
    Browse the repository at this point in the history

Commits on Jul 29, 2023

  1. Configuration menu
    Copy the full SHA
    5950372 View commit details
    Browse the repository at this point in the history

Commits on Jul 30, 2023

  1. docs: Update scripts/{env.sh -> utils}

    I moved scripts/env.sh to ./utils in 57748ff and renamed the regression
    diff functions from gdiff* to reg* in f8bf10d
    victor-gp committed Jul 30, 2023
    Configuration menu
    Copy the full SHA
    c862758 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    682bc7d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    76dd911 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    7e18cd8 View commit details
    Browse the repository at this point in the history
  5. Fix regex for lookahead_single_2_space

    Because it was matching the 2-space with the first lookahead, without
    consuming the characters it matched. Then it matched the second
    (negative) lookahead with the same 2-space. But because it's negative,
    the whole match failed.
    
    We just have to circumscribe the 2nd lookahead (negative) within the
    first one.
    
    This catches the 2 stray corner cases that I wanted to fix before
    merging this branch: one line each in chown and npm.
    
    But it also adds a hell of a regression in that it now matches plain
    text from a lot of help messages. But this can be fixed easily enough,
    cf. next commit.
    victor-gp committed Jul 30, 2023
    Configuration menu
    Copy the full SHA
    f597e53 View commit details
    Browse the repository at this point in the history
  6. Don't scope plain words with lookahead_single_2_space

    The pattern we incorrectly matched was lines including some kind of
    justified text, with ".  "
    
    We can safely match this pattern out.
    victor-gp committed Jul 30, 2023
    Configuration menu
    Copy the full SHA
    07b0b4e View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    fc97338 View commit details
    Browse the repository at this point in the history

Commits on Jul 31, 2023

  1. Configuration menu
    Copy the full SHA
    2800545 View commit details
    Browse the repository at this point in the history