Document how to trigger the native file dialog in derive and builder modes
starthal opened this issue · 1 comments
starthal commented
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 commented
I just realized the Arg
in the first snippet also needs .value_parser(value_parser!(PathBuf))
to work correctly.