rsm-hcd / AndcultureCode.Cli

and-cli command-line tool to manage the development of software applications
https://andculture.com
Apache License 2.0
14 stars 15 forks source link

Parsing short-circuits prematurely when command without flags given but no matching alias is found #110

Closed brandongregoryscott closed 4 years ago

brandongregoryscott commented 4 years ago

Looks like a missed case while testing alias feature the v1.3.0 release.

When aliases are defined (whether in the package.json or through the command registry), and the user attempts to run a command without any options (even a base command such as webpack or webpack-test), the parsing short-circuits and displays the help menu. I'm thinking we just need to move around the parsing/return to ensure we fallback to the program.parse(process.argv) if no aliases match.

Without any aliases:

bscot@BSCOTT-PC ~/proj/ (working) -> and-cli webpack-test
[and-cli] Running frontend tests (via npm run test)...

> frontend@0.1.0 test C:\Users\bscot\proj\frontend
> react-scripts test

With an alias in the package.json:

    "and-cli": {
        "aliases": {
            "testdb": "dotnet --cli -- test db migrate"
        }
    },
bscot@BSCOTT-PC ~/proj/ (working) -> and-cli webpack-test
Usage: and-cli [options] [command]

and-cli command-line tool to manage the development of software applications

Options:
  -V, --version   output the version number
  -h, --help      display help for command

Commands:
  copy            Copy files and/or directories
  deploy          Deploy various application types
  dotnet          Run various dotnet commands for the project
  dotnet-test     Run various dotnet test runner commands for the project
  github          Commands for interacting with AndcultureCode github resources
  install         Collection of commands related to installation and configuration of the and-cli
  migration       Run commands to manage Entity Framework migrations
  nuget           Manages publishing of nuget dotnet core projects
  testdb          (alias) dotnet --cli -- test db migrate
  webpack         Run various webpack commands for the project
  webpack-test    Run various webpack test commands for the project
  help [command]  display help for command

Having > 3 arguments (such as a command & some options) seems to be working.

bscot@BSCOTT-PC ~/proj/ (working) -> and-cli dotnet -cRb
[and-cli] Recursively deleting 'bin' directories...
[and-cli] 'bin' directories deleted successfully!
[and-cli] Recursively deleting 'obj' directories...
[and-cli] 'obj' directories deleted successfully!
[and-cli] Running dotnet clean (via dotnet clean dotnet/api) on the solution...