Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#16866 closed enhancement (fixed)

Remove getopt

Reported by: michael2402 Owned by: michael2402
Priority: normal Milestone: 18.11
Component: Core Version:
Keywords: hack-weekend-2018-10 Cc:


Drop the gnu.getopt package

This is a really old C library and we would clean up our code a lot by using our own parser. This would also allow us to add common options (e.g. logging level, ...) to a common place.

Attachments (2)

remove-getopt.patch (105.8 KB ) - added by michael2402 5 years ago.
remove-getopt.2.patch (120.5 KB ) - added by michael2402 5 years ago.
... missed the test file

Download all attachments as: .zip

Change History (12)

comment:1 by michael2402, 5 years ago

Owner: changed from team to michael2402

comment:2 by michael2402, 5 years ago

While doing this I would like to drop some posix stuff that probably nobody uses (and that might be more confusing than useful). E.g.:

josm -W foo is the same as josm --foo (we did not activate this)

There are some other tweaks that are only activated if the system property gnu.posixly_correct is set (ignoring -- after short option, ...) that I will drop. An error message (e.g. missing argument) is displayed instead.

We will allow arguments to be specified before options.
So the format would be like this:

josm -o --option argument1 --with-arg=test --with-arg test -- argument2 argument3

-- is optional to mark all following arguments as non-properties to allow them to start with a -- (good for scripting)

I don't think we will break any scripts using this because only few people are aware of the tweaks you could have done using posix getopts and fewer people used them.

comment:3 by Don-vip, 5 years ago

I didn't even know about this strange syntax. No objections to drop it.

by michael2402, 5 years ago

Attachment: remove-getopt.patch added

comment:4 by michael2402, 5 years ago

The patch is complete, just needs testing (I have not really played around with the program arguments and tested the two CLI applications)

TODO for sometime during this week.

by michael2402, 5 years ago

Attachment: remove-getopt.2.patch added

... missed the test file

comment:5 by Don-vip, 5 years ago

Milestone: 18.1018.11

comment:6 by michael2402, 5 years ago

In 14415/josm:

See #16866: Drop getopt, use own option parser.

comment:7 by michael2402, 5 years ago

Resolution: fixed
Status: newclosed

Getopt is removed, let me know if there are any issues with the new parsing mechanism. I tested a few variants and added a full unit test for the parser logic, but there might be some cases that I missed.

comment:8 by michael2402, 5 years ago

In 14416/josm:

See #16866: Fix errorprone warning.

comment:9 by Don-vip, 5 years ago

In 14417/josm:

see #16866 - drop/update remaining files

comment:10 by Don-vip, 5 years ago

In 14419/josm:

see #16866 : fix PMD warnings

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain michael2402.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.