Skip to content

click.argument cannot handle negative numbers #1624

@CloudNiner

Description

@CloudNiner

Expected Behavior

I should be able to pass a negative number to a click.argument. I get the same error below if I attempt to parse a negative number as type=str or type=float. click.option works as expected.

import click


@click.command()
@click.argument("num", type=int)
def main(num):
    print(num)


if __name__ == "__main__":
    main()

Actual Behavior

Tell us what happens instead.

> python click_test.py -4
Usage: click_test.py [OPTIONS] NUM
Try 'click_test.py --help' for help.

Error: no such option: -4

Environment

  • Python version: 3.7.7
  • Click version: 7.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    f:parametersfeature: input parameter types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions