Skip to content

How to dynamically assigning global optional options to command required options? #2023

@ptr727

Description

@ptr727

I released my project using global required options used by all commands, but I now introduced commands that do not use the options, and I moved the required options to only the commands that need them.

This causes a problem for backwards compatibility, forcing users to change their commandlines from e.g.
From: foo --optionone one mycommand --anotheroption two
To: foo mycommand --optionone one --anotheroption two

I would like to keep the global options but marked them as not required, and then add the same options to individual commands but mark them as required.
But, if the option had been specified globally, I want to dynamically assign the command option from the global option, and emit a warning to the user to change the commandline, and then much later deprecate the old format.

How could I do that?

P.s. currently using Beta 4, changes in the develop branch, see here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions