florisla / stm32loader

Flash firmware to STM32 microcontrollers using Python.
GNU General Public License v3.0
109 stars 53 forks source link

Port argument parsing to argparse #40

Closed emilazy closed 2 years ago

emilazy commented 4 years ago

optparse is deprecated, and argparse provides (semi-)automatic help formatting and much better error messages.

I also added long versions of every option and converted the help strings to lowercase to conform with the conventions of the options automatically added by argparse.

Fixes #19. Fixes #38.

florisla commented 4 years ago

This is great!

Wasn't aware about optparse vs. argparse, I was even thinking about adopting click.

Let me know if you'd like to see this released quickly.

emilazy commented 4 years ago

no rush, had planned to do it ever since I saw Example: .//nix/store/5wd34znkrbxlclxc4f03ifhslm758crz-python3.7-stm32loader-0.5.1/bin/stm32loader -p COM7 -f F1 ^^

argparse isn't ideal -- like most modules in the Python standard library -- but it's flexible enough for most use-cases to be a reasonable default.