Skip to content

Support default for arguments with multiple values #2164

@tekumara

Description

@tekumara

I'd like to be able to specify a default for arguments with multiple values.

A currently failing test case:

import pytest
import click
from click.testing import CliRunner

@pytest.fixture(scope="function")
def runner(request):
    return CliRunner()

def test_multivalue_args_with_default(runner):
    @click.command()
    @click.argument('files', nargs=-1, default=['arg1'])
    def cmd(files):
        for filename in files:
            click.echo(filename)

    result = runner.invoke(cmd, ['--'])
    assert result.output == 'arg1\n'

Fails with:

TypeError: 'default' is not supported for nargs=-1.

I'm using click 8.0.3

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions