kamiyaa / joshuto

ranger-like terminal file manager written in Rust
https://crates.io/crates/joshuto
GNU Lesser General Public License v3.0
3.47k stars 154 forks source link

Problem with the file chooser argument #466

Open Rolv-Apneseth opened 11 months ago

Rolv-Apneseth commented 11 months ago

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 commented 11 months ago

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

DLFW commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 8 months ago

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.

https://github.com/kamiyaa/joshuto/blob/2536838ce31955ec55561aabb4b86fdd4bc984df/src/main.rs#L219

kamiyaa commented 7 months ago

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.

https://github.com/kamiyaa/joshuto/blob/2536838ce31955ec55561aabb4b86fdd4bc984df/src/main.rs#L219

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!