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

Refactor help option and improve option parsing from parent when default command is invoked implicitly #1934

Closed
wants to merge 35 commits into from

Commits on Aug 2, 2023

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

Commits on Aug 3, 2023

  1. Fix version() parameter type

    Borrowed from a3f0e28 that was supposed to land in the now-closed tj#1921.
    aweebit committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    e8bea4a View commit details
    Browse the repository at this point in the history
  2. Change initial variable values in test for better error messages

    (cherry picked from commit 87db4ba)
    aweebit committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    e4d00db View commit details
    Browse the repository at this point in the history
  3. Store help option instance instead of just flags

    Analogous to 3c94dfd in tj#1933 for version option.
    
    Storing the Option instance of the help option instead of just its
    flags (_helpShortFlag, _helpLongFlag) is meaningful for cases when other
    properties of the instance need to be accessed (not currently the case,
    but could be in the future).
    aweebit committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    9857b1e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    da1e153 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    35e9571 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    5128d5f View commit details
    Browse the repository at this point in the history
  7. Refactor help option

    Eliminates outputHelpIfRequested() and incorporates help option parsing
    into .parseOptions() instead for consistency with other options.
    
    Additionally, improvements to the .parseOptions() code have been made,
    first and foremost to the comments.
    aweebit committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    5b93a70 View commit details
    Browse the repository at this point in the history

Commits on Aug 4, 2023

  1. Configuration menu
    Copy the full SHA
    a12f5be View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ae0291b View commit details
    Browse the repository at this point in the history
  3. Check for undefined in Option.is()

    Eliminates the need for the check in other places.
    
    (cherry picked from commit a12f5be)
    aweebit committed Aug 4, 2023
    Configuration menu
    Copy the full SHA
    97f3069 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    261a9d6 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    7335a9c View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    74c1d4e View commit details
    Browse the repository at this point in the history
  7. Handle obscured help flags and help for default command correctly

    Achieved by giving up the earlier introduced 'option:' events for help
    and a better .parseOptions() design.
    
    The default command now concedes the help option to the parent in
    exactly the same cases in which all other options would be conceded.
    aweebit committed Aug 4, 2023
    Configuration menu
    Copy the full SHA
    f511028 View commit details
    Browse the repository at this point in the history
  8. Refactor parseOptions() to a good library function

    Add a displayHelp property to the returned object indicating whether a
    help flag had been found before encountering a subcommand, or before
    giving up option processing in favor of subcommands due to passThroughOptions being enabled.
    
    Before encountering a subcommand, the help option is now consumed in
    exactly the same cases any other option would be consumed.
    aweebit committed Aug 4, 2023
    Configuration menu
    Copy the full SHA
    87ed7ea View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    02fde0e View commit details
    Browse the repository at this point in the history
  10. Make passThroughOptions continue processing at unknown options

    So that the help option is correctly consumed.
    aweebit committed Aug 4, 2023
    Configuration menu
    Copy the full SHA
    eae6c5f View commit details
    Browse the repository at this point in the history

Commits on Aug 5, 2023

  1. Configuration menu
    Copy the full SHA
    de710a5 View commit details
    Browse the repository at this point in the history
  2. Handle help option specially in parseOptions()

    Only the help flags are consumed after an unknown option is encountered
    and before a subcommand or a command-argument is encountered when using
    passThroughOptions.
    
    As a result, when a help flag is encountered in this stage of option
    processing,
    - the help is consumed by the parent command rather than by the
      subcommand if a subcommand is encountered later or a default
      command is provided;
    - the help is displayed instead of an unknown option error
      even when not using allowUnknownOption.
    aweebit committed Aug 5, 2023
    Configuration menu
    Copy the full SHA
    31c03c7 View commit details
    Browse the repository at this point in the history
  3. Improve default command handling in parseOptions()

    Only stop processing from parent when a sub-subcommand or a
    command-argument is encountered. Before that, known options found after
    an unknown one are consumed by the parent, including the help option.
    aweebit committed Aug 5, 2023
    Configuration menu
    Copy the full SHA
    aaf23bb View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d1fd350 View commit details
    Browse the repository at this point in the history
  5. Improve comment on passThroughOptions

    Includes a partial fix for tj#1936 (docs need an update, too)
    aweebit committed Aug 5, 2023
    Configuration menu
    Copy the full SHA
    b11e940 View commit details
    Browse the repository at this point in the history
  6. Refactor if statements

    aweebit committed Aug 5, 2023
    Configuration menu
    Copy the full SHA
    58b3003 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    04be1b5 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    0bab7e7 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    cd8ded5 View commit details
    Browse the repository at this point in the history
  10. Rework comment on passThroughOptions

    (cherry picked from commit a8b656d)
    aweebit committed Aug 5, 2023
    Configuration menu
    Copy the full SHA
    cac1f8a View commit details
    Browse the repository at this point in the history

Commits on Aug 6, 2023

  1. Fix implicit default command starting with unknown option

    Reverts to original conditionals structure so that implicitly invoked
    default commands behave as if the command name came before the first
    arg that is not a known option, and not as if it came before the first
    arg that is not an option (known or unknown) like previously.
    
    Fixes pass through and handling of options after the unknown for
    implicitly invoked default commands.
    aweebit authored Aug 6, 2023
    Configuration menu
    Copy the full SHA
    e7c790a View commit details
    Browse the repository at this point in the history
  2. Refactor parseOptions()

    Eliminates redundant calls and checks.
    aweebit committed Aug 6, 2023
    Configuration menu
    Copy the full SHA
    dd2c9c8 View commit details
    Browse the repository at this point in the history

Commits on Aug 11, 2023

  1. Refactor parseOptions()

    - Store onlyKnownOptionsSoFar value instead of computing
    - Removed passThroughOptions comment considered unclear (see tj#1942)
    
    (cherry picked from commit d7e2399)
    aweebit committed Aug 11, 2023
    Configuration menu
    Copy the full SHA
    f8e5faf View commit details
    Browse the repository at this point in the history

Commits on Aug 12, 2023

  1. Revert "Fix version() parameter type"

    This reverts commit e8bea4a.
    aweebit committed Aug 12, 2023
    Configuration menu
    Copy the full SHA
    a253ec6 View commit details
    Browse the repository at this point in the history

Commits on Aug 13, 2023

  1. Configuration menu
    Copy the full SHA
    8dd417f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    513a4b5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e01bb9a View commit details
    Browse the repository at this point in the history