-
Notifications
You must be signed in to change notification settings - Fork 145
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
Add long options like --part #1936
base: main
Are you sure you want to change the base?
Conversation
Switch the command line argument parser from getopt(3) to getopt_long(3) and add a few long options as aliases to existing short options, e.g. "--help" and "--part" being aliases for "-?" and "-p", respectively. The getopt_long(3) function is available on GNU, BSD, and the existing msvc/getopt.[ch] already implements getopt_long() on Windows. This should cover all systems avrdude supports. Adapt the avrdude usage message shown by "-?" or "--help" to show the new long options. TODO: Adapt man page and texi manual reflecting the long options. Closes: avrdudes#1922
c012638
to
818e0e8
Compare
{"quiet", no_argument, NULL, 'q'}, | ||
{"reconnect", no_argument, NULL, 'r'}, | ||
{"terminal", no_argument, NULL, 't'}, | ||
{"tty", no_argument, NULL, 't'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I look at the list carefully, I don't think tty
is a good long option name to signify -t
for the principal reason that tty describes a communication method (teletype), which is orthogonal to what -t
does. Terminal input can come from a file, from a pipe, via a USB connection etc and not necessarily from a tty. I'd prefer to either have no second long option for -t
, but if there is an appetite for a second option, I'd much rather have one of --interactive
, --console
, --avr-console
, --shell
or similar. We normally use the wording terminal or interactive terminal in the documentation for -t
, so --terminal
might be sufficient.
Could we add --terminal-command
for -T
(note capital T), which like -U
is not interactive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"shell" implies turing completeness. "interactive" captures the spirit well.
{"reconnect", no_argument, NULL, 'r'}, | ||
{"terminal", no_argument, NULL, 't'}, | ||
{"tty", no_argument, NULL, 't'}, | ||
{"memory", required_argument, NULL, 'U'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--memory
is a good long option name b/c it puts the focus correctly: the operations r
, w
and v
all refer to memory and, crucially, not the corresponding file; originally -U
got its name from the generic update operations it might describe, so I would also allow the mnemonic --update
or, alternatively, --update-memory
. I have an ever so slight preference for the latter: personally, I think long options are good in shell scripts to improve readability, so I am less worried about the length of long options. If we go with the latter, we wouldn't need --memory
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would argue that --memory
would be sufficient. The help test will get awfully long if we have tons of long options that to the same thing. And the -U flag doesn't necessary updates the memory.
IMO, --memory flash:r:myfile.hex
makes way more sense than --update-memory flash:r:myfile.hex
.
{"noerase", no_argument, NULL, 'D'}, | ||
{"erase", no_argument, NULL, 'e'}, | ||
{"logfile", required_argument, NULL, 'l'}, | ||
{"test", no_argument, NULL, 'n'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-n
meant originally don't write to the AVR part for -U
operations, where -n
would write the file to stdout instead of the AVR memory. When other ways to write to the AVR were implemented (-t
, -T
, ...) there was no way to test these in a dryrun as it were until the -c
programmer dryrun
was implemented. I now wonder whether --test
should be --test-U
or rather --test-update
to clarify the role of that option.
Cool improvement! I like this PR |
I'm happy with the PR, but I have a few suggestions, based on my personal opinions:
|
I wonder whether A set of I guess |
Good idea! But how would we let the user specify the format ( :i, :r, :m etc.)?
|
There are other characters which can be used as separators. Or With long options, we are not constrained by the idiosyncrasies of the past. |
Correct. Avrdude knows three operations, some 48 memories and 12 file formats. Is the suggestion for main.c to entertain some 144 long options for all (op, memory) combos? Or 1728 long options to expand the space to all (op, memory, file format) combos? There is the added difficulty that a new part in a custom config file may well introduce a new memory, which requires new long options to automatically spring up in that case.
Projecting the And how should the command line express
That's another pitfall: Also note that allowing a different way than appending All of above can be done and done well, but should it? I believe the best thing for now is to have a one-to-one long replacement option for |
I think we should wrap it up and merge this PR. |
Note to self: The usage message should mention e.g. --part and possibly other long options. |
Switch from getopt(3) to getopt_long(3) and add a few long options as aliases to existing short options, e.g. "--help" and "--part" being aliases for "-?" and "-p", respectively.
The getopt_long(3) function is available on GNU, BSD, and the existing msvc/getopt.[ch] already implements getopt_long() on Windows. This should cover all systems avrdude supports.
getopt_long(3)
instead ofgetopt(3)
--config
--part
and--port
#1922 (comment)Closes: #1922