swift-argument-parser icon indicating copy to clipboard operation
swift-argument-parser copied to clipboard

Optional arrays

Open swiftyfinch opened this issue 3 years ago • 14 comments

It's the solution for issue #307 The author closed the issue, but I still need this one.

Checklist

  • [x] I've added at least one test that validates that my change is working, if appropriate
  • [x] I've followed the code style of the rest of the project
  • [x] I've read the Contribution Guidelines
  • [x] I've updated the documentation if necessary

Didn't find any documentation about using arrays in Option properties.

swiftyfinch avatar May 20 '21 17:05 swiftyfinch

@natecook1000 Hey, could you validate this draft? It suits my command-line tool and now I can use it like this:

struct Rugby: ParsableCommand {
    @Option(parsing: .upToNextOption) var focus: [String]?
    
    func run() throws { print(focus) }
}
Command                         | Output
---------------------------------------------------------------------------------
rugby				| nil
rugby --focus			| []
rugby --focus Alamofire SnapKit | ["Alamofire", "SnapKit"]

swiftyfinch avatar May 20 '21 17:05 swiftyfinch

@swift-ci please test

swiftyfinch avatar May 21 '21 03:05 swiftyfinch

Thanks for this, @swiftyfinch — I'm not totally convinced that this is the right design to solve this issue, but it does seem sensible. Can you make sure the behavior makes sense / add tests for using this with the other parsing strategies? We'll also want an initializer that works with non-ExpressibleByArgument types.

natecook1000 avatar May 22 '21 03:05 natecook1000

@natecook1000 Okey, I will try) How can I run checks with @swift-ci?

swiftyfinch avatar May 22 '21 12:05 swiftyfinch

@swiftyfinch I think only committers can kick off CI… Just let me know when you're ready for review!

natecook1000 avatar May 22 '21 16:05 natecook1000

  • [x] Finalize handling all parsing strategies
  • [x] Add non-ExpressibleByArgument init
  • [x] Add more tests for the most part of cases

@natecook1000 Ready for review

swiftyfinch avatar May 23 '21 07:05 swiftyfinch

@swift-ci Please test

natecook1000 avatar May 24 '21 16:05 natecook1000

@natecook1000 I fixed compile error. Please, run tests again.

swiftyfinch avatar May 25 '21 03:05 swiftyfinch

@swift-ci please test

kylemacomber avatar May 25 '21 15:05 kylemacomber

@natecook1000 @kylemacomber Hey, any updates here?

swiftyfinch avatar May 28 '21 06:05 swiftyfinch

Any updates?

swiftyfinch avatar Jun 11 '21 09:06 swiftyfinch

@natecook1000 @kylemacomber Hey, do I need to resolve conflicts or this solution doesn't have a chance to be merged? Just let me know if you are waiting for me. There weren't any updates last three months.

swiftyfinch avatar Sep 19 '21 18:09 swiftyfinch

Bumping this, as this feature would be nice.

mwielgoszewski avatar Sep 30 '22 03:09 mwielgoszewski

Bumping this.

vlm avatar Sep 03 '23 03:09 vlm