xclip icon indicating copy to clipboard operation
xclip copied to clipboard

Special case for xclip to support --help

Open EdwardBetts opened this issue 8 years ago • 2 comments

When somebody tries a new tool they're likely to try --help to find how to use it.

This commit adds a special case to show the usage information when called with --help as the first argument.

EdwardBetts avatar Nov 19 '17 16:11 EdwardBetts

xclip already has "-h" and "-help". I don't think we should add a special exception just for help. We could consider supporting both single and double dashes for all options like, for example, vncviewer, but I'm not sure it is worth it.

astrand avatar Nov 20 '17 07:11 astrand

I believe that if it is easy, it is completely worth it. Using double-dashes is the norm for most UNIX applications I use and I have to remind myself that xclip will get confused if I do that. However, I understand parsing the command line arguments using XrmParseCommand(3) severely restricts what can be done and it might not even be possible.

Since the command line parsing is fairly simple, it might make more sense to switch over to GNU's getopt_long_only(3) which handles both single and double dash long options as well as short options. I believe current users would not notice any difference, except that incorrect arguments like "-targets" won't give the error message: "No such file or directory".

It may seem strange to depend on a GNU extension, but the BSD systems implemented a getopt_long_only workalike. I haven't seen a UNIX machine without it in a long, long time.

Still, I can understand if that's not acceptable for portability reasons or if it is very important to use the Xresources Database for options.

However, at the least, it shouldn't harm anything to accept this patch. It would alllow novice users to use '--help' and adds only a few extra lines. It wouldn't even need to be a documented or supported feature, just a nicety for those first learning xclip who stumble upon it.

hackerb9 avatar Oct 12 '19 09:10 hackerb9