Closed deadPix3l closed 5 years ago
A quick google search turned up this: https://stackoverflow.com/a/49838142
Looks like we can just do something like this:
from commands import xxd
args = ['--arg1', 'asdf', '--arg2', 'qwer']
c = xxd()
c.get_parser().parse_args(args)
In order to support running tools programmatically, you can pass arguments as a list of strings to parse_args() (or via get_args() in this case). Passing None will default to usual commandline behavior.
When should this list be passed?
Note: this will not effect how the command line parsing operates. only how it is called from repl and unit tests.
the first option would require init() to save the args, and has the added benefit/curse that rerunning the object will run again with the same arguments. changing the arguments requires creating a new instance