-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update parse_options to use argparse instead of the deprecated optparse. #64
base: master
Are you sure you want to change the base?
Conversation
Fix 'extra_options' so that meaningful and complete command line options can be added on invocation.
Remove extraneous test print statement
👍 |
Can we have this merged? By the way, I don't see how this solves #54. I suspect the OP there wants something along the lines of this
being equivalent to this
|
Instead I propose we fix the existing bugs exposed by the test suite, merge this update, and release fabricate 2.0. What do you think @rmatev? |
@chriscz agreed. Do we drop 2.6 support after fabricate 2.0? |
Yes, this will be part of 2.0 at which point we will drop 2.6 support. |
base runner class missing _builder. add init for it and propogate changes to subclasses to call base class init. refix args after I broke it during upstream merge.
add ability to generate BIN files and UF2 files for bootloader
Hey @stevenj It looks like you've added quite few unrelated scripts to this PR. Would you mind if I just merge up to the replacement of |
no, i don't mind at all. |
Fix 'extra_options' so that meaningful and complete command line options
can be added on invocation.
fixes #54
extra command arguments is strange in existing fabricate.py and i couldnt find a useful example to use them. Also, optparse is deprecated. So in making the extra_options actually useful, i also updates parse_options to argparse.
To use extra_options one needs to pass an array of dictionaries as the parameter to extra_options, like this:
the reason for this is that argparse.add_argument (and optparse.make_option before it) require keyworded parameters to be able to fully use them. The keywords are expressed as the keys to the dictionary, and are automatically extracted into an option list using ** argument expansion.
'name_or_flags' is special, it is for un-keyworded arguments, to define the name or flag of the option, its value is an array of strings, specifying the 'name' or the 'flags' or both. Again it is turned into an argument using * argument expansion.
Im not 100% happy with this method, as its a bit obtuse, but i couldn't see a more straightforward way to achieve it. I don't think this is backward compatible with the old use of 'extra_options' but as far as i could tell it didn't have any good use as it was.
to use your new option, just refer to
main.options.\<option\>
in the example above that would be:main.options.bdir