Default Values - Documentation Doubt


I have a doubt about default values in the documentation - Declaring Arguments, Options, and Flags

An option or argument with a default parameter can also be omitted by the user.


  1. How to add default values to an argument ? (I thought default values could only be specified for @Option.)

You're right there — you can't currently provide a default value for an argument. Arguments with optional or array type have an implicit default, but there's no default parameter for other cases like there is with options and flags. I'll update the documentation!

1 Like

@nnnnnnnn Thanks a lot for the clarification.

I have one more doubt:

While using @Flag with an Int property the help seems to display as follows:

struct Test : ParsableCommand {
    var numberFlag : Int //can be omitted
    func run() throws {
        print("numberFlag = \(numberFlag)")


--help shows the following:
USAGE: test [--number-flag ...]


  • There is [--number-flag ...] seems like an array, is this a bug ?
1 Like

It would count the number of times the flag appears.


@Lantua Thanks a lot, I didn't think that far.
You are right repeating it twice gives 2.

This is just such a lovely framework really enjoy using it, thanks to everyone who worked on it

1 Like