Skip to content

Wrong argument handling when specifying 'ignore_unknown_options' in combination with options #602

@cbandera

Description

@cbandera

I am having trouble with argument handling when specifying the 'ignore_unknown_options' in combination with options.

In this specific case, I need to use the 'ignore_unknown_options' flag in order to pass a unknown amount of arguments AND options to an underlying process. (And prevent click from interpreting words beginning with a dash '-' as options).

At the same time, whenever you have an option specified with a letter, click will still steal this single letter from the argument.

Consider this minimal example:

import click

@click.command(context_settings=dict(ignore_unknown_options=True, ))
@click.option('-y', '--default_yes')
@click.argument('compiler_args', nargs=-1)
def cli(  default_yes, compiler_args):
        print(compiler_args)

When called with
cli -DCMAKE_CXX_FLAGS=-Wreturn-type
it will print
(u'-DCMAKE_CXX_FLAGS=-Wreturn-t',)
and cut the rest off.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions