tspivey / tdsr

A console screen reader for macOS and Linux
GNU General Public License v3.0
78 stars 18 forks source link

Add plugin functionality #35

Closed hbk619 closed 7 months ago

hbk619 commented 8 months ago

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 https://github.com/tspivey/tdsr/issues/33

I've pushed a plugin repo to show how you could share plugins. Cloning that repo into plugins/ and then configuring with the right folder/file names works with this branch :smile:

hbk619 commented 8 months ago

I ensured we don't overwrite existing keys in the add method of Keyhandler. Should I add feedback if there is an existing shortcut?