I am using the Alexa Gadget Toolkit Python package to create an IoT device. (https://github.com/alexa/Alexa-Gadgets-Raspberry-Pi-Samples/tree/master/src/agt)
Following from Amazon's example scripts, the IoT class is defined and executed as:
from agt import AlexaGadget
class MyGadget(AlexaGadget):
...
if __name__ == "__main__":
MyGadget().main()
I'd like to add an additional "test" argument to my gadget script (to enter a testing mode), so I am using argparser
.
import argparse
from agt import AlexaGadget
class MyGadget(AlexaGadget):
def main():
super().main()
parser = argparse.ArgumentParser()
parser.add_argument("--test", action="store_true", required=False)
args = parser.parse_args()
if args.test:
# Do something here
However, when I do this, reagardless of whether or not I call the super().main()
before or after defining parser
, I receive:
usage: mygadget.py [-h] [--pair] [--clear]
mygadget.py: error: unrecognized arguments: --test
Looking at the AGT class, they also use argparser
to define arguments related to the Bluetooth functionality.
Since it is already defined in the parent, how can I also capture my own arguments in my child without modifying Amazon's AGT class?
Thanks!