Add a command fileopen to open files in external programs#200
Open
rsekman wants to merge 10 commits intorndusr:masterfrom
Open
Add a command fileopen to open files in external programs#200rsekman wants to merge 10 commits intorndusr:masterfrom
fileopen to open files in external programs#200rsekman wants to merge 10 commits intorndusr:masterfrom
Conversation
Owner
|
Thank you. I've had this on my todo list aswell.
1. Please squash your fixup commit so it is easier for me to review.
2. "Ugly hack to make the command behave as expected in the tui" doesn't tell me
much. Can you explain what this hack does exactly and why it is needed?
3. It doesn't look like you need mixin.polling_frenzy. This is only needed if
you make a request that changes state in transmission-daemon (e.g. stop a
torrent) and you want to display that change ASAP in the TUI.
4. I haven't tried, but it looks like a failing command doesn't tell me what
went wrong, and a command that only prints to stdout does nothing.
Maybe you can subclass something like TextIOWrapper[1] and delegate write()
calls to self.info() for stdout and self.error() for stderr.
5. Once I'm happy with the PR, tests would be nice if you have the time.
[1] https://docs.python.org/3/library/io.html#io.TextIOWrapper
|
Contributor
Author
|
Hi, thanks,
|
Owner
|
1. I have some minor style complaints (read the next point first):
***@***.***: Missing empty line above the method
***@***.***: Missing empty line above the method
***@***.***: Missing empty line above the method
***@***.***: Missing empty line below the method
***@***.***: Surplus empty line
***@***.***: Missing two empty lines above the class
2. It's been a long time since I've worked on this. After reading my own code
and docs for a while, I think my plan for this was to make a stupid "run"
command that just executes a command and logs the output. The "interactive"
command should be able to supply the file/torrent path to "run". Something
like this:
:bind --context file interactive "run --quiet mpv -f '{location}/{path}'"
:bind --context torrent interactive "run --quiet mpv -f '{location}'"
This approach should drastically reduce the added code. The downside is that
this doesn't work on the CLI. Is "stig fopen ..." important to you?
4. I agree that a --quiet/-q option would be best to ignore stdout. Maybe count
the number of --quiet arguments and also silence stderr if >= 2.
Check out the "bind" command, which also accepts options and a command.
5. The tests were written in the Wild West. No docs or even a guide. You can
look at existing tests for inspiration, but don't look too closely, I didn't
really know what I was doing. :)
|
subprocess.run blocks. This means that the child process must exit before the user can contine to interact with stig. Using subprocess.Popen instead fixes this. Using pipes and asyncio, stdout and stderr from the child process will appear asynchronously in the log.
pass twice to also suppress stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.