Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Space-separated subcommands #51

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Commits on Nov 14, 2018

  1. feat: space-separated subcommands

    Previously, `Main.run` considered the first item in `argv` array a command ID, for example, in the `['user:add', 'Peter']` array, the command was `user:add` and the rest were its args. This doesn't work with space-separated commands which produce `argv` array like this:
    
    ```
    ['user', 'add', 'Peter']
    ```
    
    and would be parsed as a `user` command that gets `add` and `Peter` as args.
    
    The new implementation looks at `config.commandIDs` and tries to find the longest match with items from `argv`. For example, if `commandIDs` contained `user` and `user add` commands, the new implementation would invoke a `user add` command with `['Peter']` as args. If, on the other hand, `commandIds` only contained the `user` command, it would invoke a `user` command with `['add', 'Peter']` as args.
    
    A couple of notes:
    
    - It's up to @oclif/config (or possibly a plugin) to produce command IDs that contain spaces. As of @oclif/[email protected], the command IDs contain a colon, e.g., `user:add`.
    - The change is backwards compatible. Argv `['user:add', 'Peter']` is still parsed as command ID `user:add` and `['Peter']` as args.
    - The command separator is currently hardcoded to be a space. If oclif introduced a new config option like `"separator": "<any_character>"`, the argv splitting logic should be updated.
    - The `splitArgv` function should be unit-tested. I didn't find a testing infrastructure in this package, will seek advice on how to best do it.
    borekb committed Nov 14, 2018
    Configuration menu
    Copy the full SHA
    0e93f2f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6eebaf5 View commit details
    Browse the repository at this point in the history

Commits on Nov 15, 2018

  1. Configuration menu
    Copy the full SHA
    4aa3dfe View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3d57da5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ef31048 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    42179f4 View commit details
    Browse the repository at this point in the history