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

Document how to trigger the native file dialog in derive and builder modes #44

Open
starthal opened this issue Aug 24, 2022 · 1 comment

Comments

@starthal
Copy link

Thanks for this crate!

It isn't clear (to me) from the documentation how to tell Klask to use a native dialog for a PathBuf argument.

I noticed the following:

use std::path::PathBuf;
use clap::{Arg, App, ValueHint};
use klask::Settings;

fn main() {
    // Displays path picker
    let app = App::new("Foo").arg(Arg::new("path").value_hint(ValueHint::FilePath));
    klask::run_app(app, Settings::default(), |matches| println!("Path: {:?}", matches.get_one::<PathBuf>("path")))
}
    
fn main() {
    // Displays string field
    #[derive(clap::Parser)]
    struct Args {
        path: PathBuf
    }
    klask::run_derived::<Args, _>(Settings::default(), |args| println!("Path: {:?}", args.path))
}

Is it possible to trigger the native dialog without supplying a ValueHint directly? If so, this could be helpful to note in the docs.

@starthal
Copy link
Author

I just realized the Arg in the first snippet also needs .value_parser(value_parser!(PathBuf)) to work correctly.

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

1 participant