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

File chooser: creating a new file #32

Open
alexjago opened this issue Feb 14, 2022 · 4 comments
Open

File chooser: creating a new file #32

alexjago opened this issue Feb 14, 2022 · 4 comments

Comments

@alexjago
Copy link

alexjago commented Feb 14, 2022

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

@MichalGniadek
Copy link
Owner

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
Copy link
Author

alexjago commented Feb 14, 2022

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
Copy link
Owner

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
Copy link
Owner

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

  • Setting an alias of a field to some value would make it an "input file" field. There's a small chance someone could misspell a field when using the app as CLI and type it by mistake, but it seems unlikely.
  • Setting a value name to some value would make an "input file" field. This would change the help message displayed by clap.

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