-
Notifications
You must be signed in to change notification settings - Fork 346
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
Check if module options are given more than once #5608
Conversation
This is a possible solution to the issue discussed in #5604.
Anyone have any thoughts or opinions on this one? |
The solution looks good to me, but I doubt that someone can write a clever Python script or C program to do the job. |
Game on, @seisman! |
Not a script, but this should do. Will have to manually override the very few places (e.g., -G in grdtrack) where repeated options are allowed:
|
This PR concludes my initial goal: to ensure that giving unique module options more than once will yield an error. I used the C code above to do most of the lifting. There were a few more corner cases that I forgot: We have many cases that are deprecated so there is no The update thus affected almost every single module code. A few options did not have a As an example of what happens with a duplicate option, see this:
All tests pass. I suggest @meghanrjones and @joa-quim test this branch with PyGMT and GMT.jl to ensure that any problems are not in GMT but on the wrappers, and we can then approve and merge. |
PyGMT tests pass. |
Let me know if any issues with Julia tests, @joa-quim . |
So far no problems, tests pass, but I'm certain this will cause me some grief in future. |
Thanks. But think of it as better checking and you will be notified right away if you are coding something up incorrectly! Care to approve? Meghan is off this weekend. |
Na. I actually would prefer that complicated options could be broken in pieces like -B. |
This is a possible solution to the issue discussed in #5604. If you build and run this command you can see the solution in action:
echo 0 0 1 | gmt xyz2grd -R-1/1/-1/1 -I1 -Gout.nc -Af -An
Currently, we mostly accept repeated module options (other than GMT common options) and that is bad since there is no feedback to the user, and there is no way to know which entry the user wanted. There are two solutions here:
I am open to thoughts on this, @GenericMappingTools/core, but as users can turn off warnings I think an error is cleaner (since it is an error).