So I've imported ScrambleEbook into a git repository here:
https://github.com/eli-schwartz/ScrambleEbook
And this patch implements the CLI interface:
https://github.com/eli-schwartz/Scra...775c440f515b85
Notice it's pretty simple to do. The heart of it is in __init__.py, where ScrambleEbookActionBase needs to be extended with a new method: cli_main(), which is responsible for initializing a new application and doing all that good stuff.
The thing that cli_main does is the same thing that running scrambleebook.py on its own needs to do: call a QApplication, set up the EbookScramble(QDialog), and exec the QApplication. Luckily, all that is already in a
Code:
if __name__ == '__main__'
, so I could simply shift the lines around, turn it into a main() function that is then called by if __name__ ..., and rewire it to pass sys.argv around
sliiiiiightly different, so that I can pass my own array into main() if I really want to.
And then cli_main() runs calibre_plugins.scrambleebook_plugin.scrambleebook .main -- that's all.