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

Problem with the file chooser argument #466

Open
Rolv-Apneseth opened this issue Nov 28, 2023 · 9 comments
Open

Problem with the file chooser argument #466

Rolv-Apneseth opened this issue Nov 28, 2023 · 9 comments

Comments

@Rolv-Apneseth
Copy link

I hope I'm not being blind but I can't find how to use the --file-chooser argument for this program. It is not mentioned in this doc page.

When I run joshuto --file-chooser, the program works fine but exits with an error (102) after selecting a file. I would expect it to either output straight to stdout or take an output file as an argument, so though I'm not even sure it makes sense, I also tried joshuto --file-chooser --output-file temp.txt and the result is the same.

Any support would be appreciated, thanks.

@topongo
Copy link

topongo commented Nov 29, 2023

I didn't know about this feature, and because I'm very interested in it, I can see if I find some clues

@DLFW
Copy link
Contributor

DLFW commented Nov 29, 2023

Hi!
Try this:

joshuto --file-chooser --output-file ~/my-temp-file

The selected file is written to the given temp-file.

It's for example used in this NeoVim plugin, which add Joshuto as a way to open a file.

@Rolv-Apneseth
Copy link
Author

Ah yes that seems to work thanks. It does still exit with an error though but I guess as long as it works it's fine.

And that's funny, thanks for sharing that plugin, that's exactly the kind of thing I was looking to do

@DLFW
Copy link
Contributor

DLFW commented Nov 29, 2023

Hmmm, not exactly an error, I guess: https://github.com/kamiyaa/joshuto/blob/6cabeb9c8308e5debc9eda3ef8dadda268545156/src/commands/quit.rs#L22C20-L22C20

If this is really not documented somewhere, I agree, it should be...

@Rolv-Apneseth
Copy link
Author

I don't know much about exit codes to be honest, but shouldn't it be 0 if there was no problem with the operation?

@kamiyaa
Copy link
Owner

kamiyaa commented Dec 19, 2023

Hmmm, not exactly an error, I guess: https://github.com/kamiyaa/joshuto/blob/6cabeb9c8308e5debc9eda3ef8dadda268545156/src/commands/quit.rs#L22C20-L22C20

If this is really not documented somewhere, I agree, it should be...

Yeah, I should document it somewhere

@kamiyaa
Copy link
Owner

kamiyaa commented Dec 19, 2023

I don't know much about exit codes to be honest, but shouldn't it be 0 if there was no problem with the operation?

Yeah, usually 0 means success. Non-zero means an error, but can also be used to communicate other things

@dgmcdona
Copy link

Should this be println! and not eprintln!? Personally, I'd rather have this sent to stdout than stderr. Also, for some reason the file list doesn't even output to stderr as-is, but when I recompile with println! instead, the files display to stdout as expected.

eprintln!("{}", file.display());

@kamiyaa
Copy link
Owner

kamiyaa commented Apr 3, 2024

Should this be println! and not eprintln!? Personally, I'd rather have this sent to stdout than stderr. Also, for some reason the file list doesn't even output to stderr as-is, but when I recompile with println! instead, the files display to stdout as expected.

eprintln!("{}", file.display());

ratatui/termion (not sure which one) doesn't allow for joshuto's output to be piped.

This makes it a bit tricky to get joshuto to work with shell scripts.
Because you can't just do file_path=$(joshuto --file-chooser) because the output is piped.

So the only other option is to pipe it to a file.

joshuto --file-chooser > some_file.txt

But this won't work either because joshuto outputs to stdout, which gets piped to the file.

So the only sensible solution is to have

joshuto --file-chooser 2> some_file.txt

Hope this clears things up!

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

5 participants