Skip to content

Support passing a negative number as an argument #31

@alexito4

Description

@alexito4

Imagine a command like this

import ArgumentParser

struct Absolute: ParsableCommand {
    
    @Argument() var number: Int
    
    func run() throws {
        print(abs(number))
    }
}

Absolute.main()

you can run

command 5

and it works. but running

command -5

fails with Error: Missing expected argument '<number>' which makes sense.

I would have expected being able to pass the argument as "-5" but that doesn't work either.

Any advice on how to handle this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions