-
Notifications
You must be signed in to change notification settings - Fork 52
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
Added long options to squash command. #151
Conversation
Every long option program I've ever used has separated multi-word options with a dash, not an underscore. |
Thanks for the patch! @Dr-Emann is right, definitely use dashes not underscores. Also, Travis spotted some issues; the
while ((opt = parg_getopt_long (&ps, optend, argv, "c:ko:123456789LPfdhb:V", squash_options, &long_index)) != -1) {
if (opt == 0)
opt = squash_options[long_index].val;
switch (opt) {
... Finally, when declaring the |
Fair enough on the dashes vs underscores, I've never realized until now that I too cannot recall anyone using underscores in long options. Yeah that & was a bad copy-paste error from a getopt example. Updated the 0's to NULLs where the arguments are pointers in the option array. Lastly, I updated "file" to be "force" and removed the argument requirement. However, I'm not following on why parg_getopt_long won't work the way it's coded here (although the Travis CI build failure would indicate otherwise I did actually test this before I sent the PR). On my machine the current code (as originally submitted) builds on my machine (OS X) and parses the long options without a problem. Although I agree one could use the long index parameter, right now parg_getopt_long is just returning the same character for the long option as its corresponding short option so the while loop should work just the same. Just for kicks I tested this by printing out the value of opt:
|
Ah, you're right, sorry. I was misreading the parg documentation; it's only an issue if the
I have Travis set up to build with -Werror, but that isn't the default for Squash since it can easily cause build errors when people (try to) use a compiler or compiler version we haven't tested with. Anyways, thanks for the patches, they're greatly appreciated. |
First pass at Issue #147. Let me know if you have any feedback and I'll update the PR.