-
Notifications
You must be signed in to change notification settings - Fork 605
feat: allow custom exit code with quit --code
#2609
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
Conversation
This is useful to integrate yazi into a workflow with other tools. An example for this is the pager for https://github.com/aurutils/aurutils
It's unclear to me why this is needed:
|
The workflow in aurutils is the following: It opens a directory (the build directory for an aur package) with an external program (aurutils calls it a "pager", though I find this a bit of a weird name). The user inspects the directory (peeking into files and such) and then returns from the external program, choosing an exit code. With zero exit code, aurutils proceeds, with non-zero exit code it aborts. To be honest, I haven't seen this workflow much outside of aurutils, but I think it is actually a very general approach that makes a lot of sense to me.
correct
I don't know. Personally, I have no immediate use case for determining the exit code of yazi before I open it (and could emulate that with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
quit --code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (4)
yazi-fm/src/term.rs:92
- Consider adding tests to ensure that the custom exit code returned by goodbye is correctly handled in various production scenarios.
pub(super) fn goodbye(f: impl FnOnce() -> i32) -> ! {
yazi-core/src/mgr/commands/quit.rs:29
- Review the conversion to EventQuit to ensure that using Default::default() for the remaining fields does not override other intended values.
EventQuit { code: value.code, no_cwd_file: value.no_cwd_file, ..Default::default() }
yazi-fm/src/panic.rs:13
- Verify that returning an exit code of 1 in the panic hook is consistent with the intended behavior of the application under panic scenarios.
1
yazi-core/src/mgr/commands/close.rs:6
- [nitpick] Consider using a more descriptive name than 'Opt' to clearly indicate its role in the closing command context.
struct Opt(quit::Opt);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Align with changes from sxyazi/yazi#2609
Hi! Very cool project, I recently started using it and have a (not too obscure in my opinion) use case: When integrating yazi with other tools, it is useful to be able to return with a non-zero exit code. An example for this is the pager for https://github.com/aurutils/aurutils
I don't think it is possible to do this via a plugin (except for maybe somehow purposefully panicking from lua), so I added an option to the quit command.
Hope this is helpful.