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

Plugin functionality to customise commands #33

Open
hbk619 opened this issue Nov 19, 2023 · 2 comments
Open

Plugin functionality to customise commands #33

hbk619 opened this issue Nov 19, 2023 · 2 comments

Comments

@hbk619
Copy link
Contributor

hbk619 commented Nov 19, 2023

A colleague is using TDSR while learning programming and it's been wonderful so far. Some of the commands he runs give a lot of output e.g pytest so I added a plugin architecture to specify custom shortcuts and parse the output to something nicer. So instead of all the irrelevant stuff from pytest it will now pull out the test count, the error message and the line of code that triggered it e.g. "1 failed, 5 passed, AttributeError: 'NoneType' object has no attribute 'group', code is results = parse_output(lines)"

You can check the diff of my fork, although it has some extra things like condensing symbols.

Is this something you'd be interesting in having? I understand if you want to keep TDSR simple but if you like the idea I can tidy it up a bit and make a PR :)

@tspivey
Copy link
Owner

tspivey commented Nov 20, 2023

I'm interested in this. I can use this to add custom commands to read different parts of the screen.

@hbk619
Copy link
Contributor Author

hbk619 commented Nov 20, 2023

Thanks! Will sort out a PR. I realised the way I've imported the plugins means you can have sub modules in the plugins folder so it's super easy to have plugins from multiple repos, I'll make that clear in the documentation too 😄

hbk619 added a commit to hbk619/tdsr that referenced this issue Nov 23, 2023
With this you can now add python code to run on custom keyboard shortcuts to parse the terminal output and speak it in a more useful way.
There is a small efficiency boost by configuring the command you ran previous to pressing the shortcut and stop parsing the terminal output when found. This isn't necessary but reduces how much output a plugin gets passed which makes it faster and slightly safer (as it should stop it receiving any sensitive output).

An example use case is the pytest output, instead of all the irrelevant stuff from pytest you could now pull out the test count, the error message and the line of code that triggered it e.g. "1 failed, 5 passed, AttributeError: 'NoneType' object has no attribute 'group', code is results = parse_output(lines)"

Implements tspivey#33
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

2 participants