I'm using a python library that has a configuration step which involves calling a function and providing the API key in the prompt response. It uses input(). This function creates the file necessary with all the configurations.
This is fine for humans to use the API, but I'm adding CI to my code and wish to unit tests calls to this API. As such, I need to complete the same step.
I simply want to do something like python -c '<PYTHON CODE>'.
Aside from altering the code to allow for an optional input of the API key (to skip the prompt), I wonder if there is an easier way to do this with sys.argv.
I did some googling and could not find a working example involving input() and argument inputs.
Thoughts appreciated.
argparselibrary.argparse, but I don't see how I could pass this into a call ofapi_key = input("what's your API key? : ")input(), or using an argument parser, such assys.argvor, better,argparse, as mentioned by @enzo. Or even both, and pick one to use at runtime. It is unclear to me what exactly you want or expect as an answerinput()without modifying the original code? I just don't want it to prompt for human input.