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

Make TryFrom::try_from the default for try_from_os_str annotation #3588

Closed
2 tasks done
aj-bagwell opened this issue Mar 29, 2022 · 2 comments
Closed
2 tasks done

Make TryFrom::try_from the default for try_from_os_str annotation #3588

aj-bagwell opened this issue Mar 29, 2022 · 2 comments
Labels
A-derive Area: #[derive]` macro API C-enhancement Category: Raise on the bar on expectations S-waiting-on-decision Status: Waiting on a go/no-go before implementing

Comments

@aj-bagwell
Copy link

Please complete the following tasks

Clap Version

3.1.6

Describe your use case

All the kinds that can be used with the parse annotation have a default except for try_from_os_str. I think the most logical default would be std::convert::TryFrom::try_from. There don't seem to be and types that implement TryFrom<&OsStr> in the standard library, but it is the most obviouse trait to implement for things like file names that take a path but may not be valid.

Describe the solution you'd like

use clio::{Input, Output}
struct Opt {
    /// Would like to be able to do this
    #[clap(parse(try_from_os_str))]
    in_file: Input,

    /// Instead of this
    #[clap(parse(try_from_os_str = Output::try_from))]
    out_file: Output,
}

Alternatives, if applicable

No response

Additional Context

No response

@aj-bagwell aj-bagwell added the C-enhancement Category: Raise on the bar on expectations label Mar 29, 2022
@epage epage added S-waiting-on-decision Status: Waiting on a go/no-go before implementing A-derive Area: #[derive]` macro API labels Mar 29, 2022
@epage
Copy link
Member

epage commented Mar 29, 2022

While there might be a default for us to use, overall researching and deciding on this seems like a fairly low priority because try_from_os_str is a fairly low use case. The few people who use it can just specify it directly.

@epage
Copy link
Member

epage commented May 25, 2022

With #3732, the parse attribute is being phased out in favor of value_parser,, so I'm closing this issue.

@epage epage closed this as completed May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-derive Area: #[derive]` macro API C-enhancement Category: Raise on the bar on expectations S-waiting-on-decision Status: Waiting on a go/no-go before implementing
Projects
None yet
Development

No branches or pull requests

2 participants