Open Rolv-Apneseth opened 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
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.
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
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...
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?
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
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
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
Should this be
println!
and noteprintln!
? 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 withprintln!
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!
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 tostdout
or take an output file as an argument, so though I'm not even sure it makes sense, I also triedjoshuto --file-chooser --output-file temp.txt
and the result is the same.Any support would be appreciated, thanks.