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

Support common options shared between subcommands #2

Closed
sabberworm opened this issue May 1, 2020 · 1 comment
Closed

Support common options shared between subcommands #2

sabberworm opened this issue May 1, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request module:command command module

Comments

@sabberworm
Copy link

sabberworm commented May 1, 2020

Given the following configuration:

import { Command } from 'https://deno.land/x/cliffy@v0.4.0/command.ts';

await new Command()
    .option( '--db <database:string>', 'use given db' )
    .command( 'cmd1', new Command()
        .option( '--arg1', 'Arg 1' )
        .action( ( source: string, destination: string ) => {
            console.log( 'cmd1 called' );
        } )
    )
    .command( 'cmd2', new Command()
        .option( '--arg2', 'Arg 2' )
        .action( ( source: string, destination: string ) => {
            console.log( 'cmd2 called' );
        } )
    )
    .parse( Deno.args );

I would expect --db to become a shared option across the cmd1 and cmd2 subcommands. It seems that’s not the way cliffy handles this currently.
Instead, passing --db before the command name aborts with Unknown command: cmd1, passing it after yields Unknown option: --db.

@c4spar
Copy link
Owner

c4spar commented May 1, 2020

Thx for the issue.

At the moment shared options are not supported and in this setup --db would only be an option for the main command and not for the child commands. So you have to define the --db option for both child commands separately.

But shared options are on my list and i will implement this soon.

@c4spar c4spar added the enhancement New feature or request label May 2, 2020
@c4spar c4spar self-assigned this May 2, 2020
@c4spar c4spar added the module:flags flags module label May 3, 2020
@c4spar c4spar added module:command command module and removed module:flags flags module labels May 21, 2020
@c4spar c4spar closed this as completed May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request module:command command module
Projects
None yet
Development

No branches or pull requests

2 participants