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

Show error/warning when SubcommandDefinition contains non-existing commands #33

Open
x3rAx opened this issue Jun 29, 2017 · 0 comments
Open
Assignees
Milestone

Comments

@x3rAx
Copy link

x3rAx commented Jun 29, 2017

When defining subcommand properties like alias or brief in the parent commands subcommands export, there is no error shown, when a subcommand does not exist:

src/
+-- app.ts
+-- commands/
|   +-- default.ts
|   +-- my-command.ts
// src/commands/default.ts

import { SubcommandDefinition } from 'clime'

export const subcommands: SubcommandDefinition[] = [
    {
        name: 'my-cool-command',
        brief: "Isn't it cool?",
    }
]
$ node bin/app
  USAGE

    app <subcommand>

  SUBCOMMANDS

    my-cool-command        - Isn't it cool?
    my-command             - It's definitely cool!.

$ node bin/app my-cool-command
ERR Unknown subcommand "my-cool-command".

  USAGE

    app <subcommand>

  SUBCOMMANDS

    my-cool-command        - Isn't it cool?
    my-command             - It's definitely cool!.

As you can see, there is no such command like my-cool-command but it is displayed because it is defined in default.ts.

My suggestion is to test if the command exists (or at least if one of the files my-cool-command.js or my-cool-command/default.js exist) and to present the user with an error or at least a warning when it does not.

Example:

$ node bin/app
  USAGE

    app <subcommand>

  SUBCOMMANDS

    my-command             - It's definitely cool!.

WARN Subcommand 'my-cool-command' is defined but does not exist!

Note that the missing subcommand would not be listed as subcommand and a warning would be displayed below the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants