MichalGniadek / klask

Automatically create GUI applications from clap3 apps
MIT License
374 stars 23 forks source link

File chooser: creating a new file #32

Open alexjago opened 2 years ago

alexjago commented 2 years ago

Is there a way to specify a file to be created and saved? Obviously clap::ValueHint::FilePath works great for existing files...

MichalGniadek commented 2 years ago

Well, you can just write the path manually in the box, but there's no easier way to do it at the moment. But I'm not sure what the best way would be to specify this.

There could be just an additional button on every file path field: image But that seems a bit confusing for a user.

I can't think of any way to specify this through clap. Maybe a settings option that's a Vec<String> where you can specify singular fields which save files and not read them?

alexjago commented 2 years ago

Yeah I can't think of any way to specify it through clap, and I've just had a look. From clap's perspective there's no real difference between an input and output path. Short of asking/forking clap to add a ValueHint::NewFile. I suppose you could treat ::Other as a non-standard way of asking for a new file or something, but that's a bit of a hack.

It's definitely possible with native_dialog_rs to choose a file, so at least that shouldn't be an issue.

MichalGniadek commented 2 years ago

So, probably the best course of action would be to add a setting that allows you to specify field purpose. I won't be able to work on this for a few days, but I will try to implement it later.

MichalGniadek commented 2 years ago

Sorry for the wait. I've thought about it more, and there are two ways (both kind of hacky) to specify it in clap: