Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExpressibleByArgument, CaseIterable for enum not listing options during failure #344

Closed
2 tasks done
BadPirate opened this issue Aug 18, 2021 · 1 comment
Closed
2 tasks done
Labels
enhancement New feature or request

Comments

@BadPirate
Copy link

BadPirate commented Aug 18, 2021

When using ExpressibleByArgument for an enum @option, neither help nor error message correctly shows available options.

ArgumentParser: main
Swift version: Apple Swift version 5.3.1

Checklist

  • If possible, I've reproduced the issue using the main branch of this package
  • I've searched for existing GitHub issues

Steps to Reproduce

Create an option:

    enum Config : String, ExpressibleByArgument, CaseIterable
    {
        case ios, mac, simulator
    }
    
    @Option(help: "Build configuration")
    var config : [Config] = [.ios]

See command help screen using -h, or use the config option with an illegal value:

cli command --config invalid

Expected behavior

  1. Help should show options available
  2. Error message should show valid options

Actual behavior

  1. Help Provides no options.
  2. Error provides no useful options:
Error: The value 'invalid' is invalid for '--config <config>'
Usage: cli command [--config <config> ...] 
  See 'cli command --help' for more information.
@natecook1000 natecook1000 added the enhancement New feature or request label Aug 25, 2021
dduan added a commit to dduan/swift-argument-parser that referenced this issue Jan 1, 2022
When an option value fails to parse, no custom error message is
provided, and a list of valid candidate values is available, include the
list as part of the error message.

Addresses apple#344.
dduan added a commit to dduan/swift-argument-parser that referenced this issue Jan 4, 2022
When an option value fails to parse, no custom error message is
provided, and a list of valid candidate values is available, include the
list as part of the error message.

Addresses apple#344.
natecook1000 pushed a commit that referenced this issue Jan 5, 2022
When an option value fails to parse, no custom error message is
provided, and a list of valid candidate values is available, include the
list as part of the error message.

Addresses #344.
@natecook1000
Copy link
Member

Resolved by #382.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants