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

program.exec throwing odd error and can't figure out right way to pass options #226

Open
arsdehnel opened this issue Jan 2, 2022 · 0 comments
Assignees

Comments

@arsdehnel
Copy link

Describe the bug
I'm trying to call one command from inside another. Perhaps a weird use case but trying to have my-program wrapper call a couple child commands internally. It's working when it calls the command with no options but it's failing if I try to pass any options into the child command via program.exec( [ 'child-arg' ], options ).

To Reproduce
This is the "child" command setup:

module.exports = ( { createCommand } ) => {

    return createCommand( 'Run compliance for foo' )
        .option( '--check-only', 'Only check compliance' )
        .action( async ( { options, logger } ) => {

            console.log( 'Running compliance checks and configuration for foo' );

    } );

};

This snippet works and runs the foo command successfully.

module.exports = ( { createCommand } ) => {

    return createCommand( 'Run child commands all at once' )
        .option( '--check-only', 'Only check compliance' )
        .action( async ( { options, logger } ) => {

            program.exec( [ 'foo' ] );

    } );

};

This snippet, however, throws the error Unknown option --check-only. Did you mean --check-only ?.

module.exports = ( { createCommand } ) => {

    return createCommand( 'Run child commands all at once' )
        .option( '--check-only', 'Only check compliance' )
        .action( async ( { options, logger } ) => {

            program.exec( [ 'foo' ], options );

    } );

};

Expected behavior
The options object should be passed into the child command and applied properly.

Actual behavior
Error is thrown: Unknown option --check-only. Did you mean --check-only ?.

Environment informations (please complete the following information):

  • OS: macOS
  • OS version: 11.6
  • Shell: zsh
  • Caporal version: 2.0.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants