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

OsStr support? #30

Open
aobatact opened this issue May 21, 2022 · 1 comment
Open

OsStr support? #30

aobatact opened this issue May 21, 2022 · 1 comment

Comments

@aobatact
Copy link
Owner

Do we need OsStr support?

@epage
Copy link

epage commented Jul 29, 2022

Most uses of OsStr will be for ArgMatches which is out of the scope of clap-serde.

While the builder API has some parts that accept OsStr, it would mostly be for if someone dynamically generates the value from the system, like providing std::env::current_dir as a default. Since this can't b done with clap-serde, there doesn't seem much value.

However, thinking of the idea I put in #33, if the deserializer was made stateful, users could provide "variables" to be used in different places.

Going back to the std::env::current_dir idea, this could look like

let de = clap_serder::Deserialize::new()
    .register("current_dir", std::env::current_dir());
let cmd = de.deserialize(serde_json::Deserializer::from_str(data);

with data being

{
    "args": [
        {
            "id": "input",
            "default_value": { "variable": "current_dir" }
        }
    ]
}

(inspiration: https://github.com/rust-lang/rfcs/blob/master/text/2906-cargo-workspace-deduplicate.md#package-metadata-can-reference-other-workspace-members)

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

No branches or pull requests

2 participants