Skip to content
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 longoptions support for gmtconvert #7953

Merged
merged 8 commits into from
Nov 18, 2023
Merged

Add longoptions support for gmtconvert #7953

merged 8 commits into from
Nov 18, 2023

Conversation

rbdavis
Copy link
Contributor

@rbdavis rbdavis commented Oct 19, 2023

Description of proposed changes
Add longoptions support for gmtconvert

Python differences:

No python module found.

Julia differences:

Changed range (-Z) to transpose.
The gmtconvert manual page -Z documentation says
nothing about range.

Fixes #7952

Reminders

  • Make sure that your code follows our style. Use the other functions/files as a basis.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Describe changes to function behavior and arguments in a comment below the function declaration.
  • If adding new functionality, add a detailed description to the documentation and/or an example.

@rbdavis rbdavis requested a review from a team October 19, 2023 21:43
@joa-quim
Copy link
Member

Thanks for the -Z catch. A mistake for sure. As I said in another PR range is for those -T's

@PaulWessel
Copy link
Member

What to do about -T[d][h][selection]? We have two directives that both could be set, e.g. -Tdh, Dont think we can say --suppress=headers,data, or perhaps we can? If not, we could do a backwards compatible syntax change and turn one or both directives into modifiers +d and +h? Also, selection might be better as columns? Comments, @GenericMappingTools/long-options-review ?

BTW, I merged in 21 commits from master.

@joa-quim
Copy link
Member

--suppress=headers,duplicates looks fine to me.

@PaulWessel
Copy link
Member

--suppress=headers,duplicates looks fine to me.

Done.

@PaulWessel
Copy link
Member

@rbdavis please check that I did the short and long directives for -T correctly.

Copy link
Contributor

@remkos remkos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to have --select_number as an alias for --select_num.
Same for --select_header as an alias for --select_hdr

@PaulWessel
Copy link
Member

I would suggest to have --select_number as an alias for --select_num. Same for --select_header as an alias for --select_hdr

Agreed and done.

@PaulWessel PaulWessel requested a review from a team October 29, 2023 11:13
@joa-quim
Copy link
Member

In that sense, I would even drop the --select_num (I'll change it GMT.jl too). Regarding --select_hdr this one I think is fine to keep alongside --select_header. Using hdr to mean header is a very common practice in coding.

@PaulWessel
Copy link
Member

OK, so just --select_number then?

@PaulWessel
Copy link
Member

and the two aliases for headers

@joa-quim
Copy link
Member

For me, yes

@PaulWessel
Copy link
Member

Wait a minute. Reading -Q and it takes about a series or range of segments that should be written. I think --segments is much more to the point. select_num|select_number is not clear that these are segment numbers. So --segments=1,2,11 is much clearer, no?

@joa-quim
Copy link
Member

Yes, clearer.

@rbdavis
Copy link
Contributor Author

rbdavis commented Oct 29, 2023

Dont think we can say --suppress=headers,data, or perhaps we can?

We most definitely can NOT do this with the current parsing code. (I just tested to confirm.)

I have encountered a substantial number of options in various modules with similar structure, i.e., there are attribute-ish flags (i.e., NOT +x modifier flags) where immediately following the short-option the user may specify more than one such attribute flag in any order such as gmtselect's -I[cflrsz] option, e.g.,

% gmtselect -Ircz

So, I can certainly see how it would be a nice feature to be able to longoptify such choose-any-or-all-type attributes. However, enhancing the longoption translation code is always an adventure in discovering which of the zillion variations in existing GMT option syntax will be broken by doing so. In this case, anything that currently uses a comma character would be at risk, and in fact the comma already has particular importance for longoption translation as a special separator character between option groups in certain cases.

Paul's suggestion to change such option flag sets to a collection of modifiers, e.g.,

% gmtselect -I+r+c+x

which could then be longoptified as

% gmtselect --invert+rectangle+circle+zrange

would certainly work, although presumably you would want to both preserve the existing syntax, e.g., -I[cflrsz] , as well as add the new modifiers.

@PaulWessel
Copy link
Member

Ok will give this one more thought

@rbdavis rbdavis changed the title Add longoptions support for gmtconvert WIP Add longoptions support for gmtconvert Oct 29, 2023
@PaulWessel
Copy link
Member

This needs the new multi-directive scheme I think?

@rbdavis
Copy link
Contributor Author

rbdavis commented Nov 13, 2023 via email

@rbdavis rbdavis changed the title WIP Add longoptions support for gmtconvert Add longoptions support for gmtconvert Nov 18, 2023
@rbdavis rbdavis merged commit 3a3c000 into master Nov 18, 2023
6 checks passed
@rbdavis rbdavis deleted the longopts-gmtconvert branch November 18, 2023 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

longoption support for gmtconvert
4 participants