Test Mode
Miserlou opened this issue · 6 comments
Would you accept this change? I've started hacking on usbkill and quickly noticed that it'd be a lot easier to develop for with a test mode that didn't shut down my computer every time I wanted to use it!
This would be configurable with both --test parameters and an entry in the settings file.
[Sorry, I'm about to submit a bunch of tickets, prepare yourself! I'm a paranoid person who works out of public spaces quite a lot, and this tool makes me feel safer about leaving my laptop unattended, so I want to bend it to my will now!]
I don't think there is a real need for this. If you don't want to crash your computer, just rename the kill_computer to kill_computer_nothanks. It will crash the script instead.
[Sorry, I'm about to submit a bunch of tickets, prepare yourself! I'm a paranoid person who works out of public spaces quite a lot, and this tool makes me feel safer about leaving my laptop unattended, so I want to bend it to my will now!]
Happy to ear this! 😄
Yeah, but it isn't fair to expect that users will edit the code, especially if it's installed system-wide with pip.
With --test, end-users and developers alike will be able to test, "Does this work with my USB hub", etc, without actually killing their sessions.
I'll submit PR once we merge current pending PRs.
I can see users wanting to turn off the default shutdown code in favor of their own custom solution, though going against the main purpose of the software should definitely at least throw up a big fat info/warning message about it being disabled. Caveat emptor, after all. My recommendation would be to include a shutdown boolean that defaults to true if not defined in the config file. Then it should pop up an obvious startup message that the functionality is turned off. It should probably also error out if shutdown is false and no user-specified commands have been defined.
Yep! That's essentially how I was going to implement it.
test would be something for users, instead I added a dev mode which developers can use by adding the argument --dev.
--dev overwrites the the kill_computer function with a sys.exit message. More complex dev mode kill functions can now be implemented in a consistent way.
Awesome! 👍