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

Make Token.Symbol property public #1815

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Commits on Aug 13, 2022

  1. Make Token.Symbol property public

    Motivation:
     - Inside custom middleware, it may be desirable to understand relative order of symbols in the parsed command line (for e.g. in the case of several option types that influence a shared setting and that have a "last option specified wins" semantic).
     - Best way to do understand sequence order is by inspecting the `ParseResult.Tokens` list. This gives `Token`s, which contain embedded symbol references.
     - From there, we'd like to compare the token's `Symbol` directly against predefined `Argument` and `Option` objects to ease identification.
     - Doing this from non-`internal` code today requires something like `if (tokenOfInterest == new Token(tokenOfInterest.Value, TokenType.Option, optionOfInterest)) { /* match */ ... }`, which works because of the overridden `Token.Equals` method.
     - It'd be much easier to say `if (tokenOfInterest.Symbol == optionOfInterest) { /* match */ ... }`
     - No clear reason why `Token.Symbol` needs to be `internal`
    kahlkevin committed Aug 13, 2022
    Configuration menu
    Copy the full SHA
    3bb09e9 View commit details
    Browse the repository at this point in the history