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

Use thirdparty GNU style flag packages #42

Closed
yegle opened this issue Feb 25, 2015 · 5 comments
Closed

Use thirdparty GNU style flag packages #42

yegle opened this issue Feb 25, 2015 · 5 comments

Comments

@yegle
Copy link

yegle commented Feb 25, 2015

The flag package in golang doesn't support combination of short flags.

e.g. in GNU style, -help means -h -e -l -p, and -n1 means -n=1.

But in Go -help means --help, and -n1 means --n1. Without a proper GNU style flag parser, there's no easy way to support things like tail -n10.

Here's a short list of packages I googled that do GNU style flag parsing:

I'll be happy to provide some PR if any of the packages are accepted as replacement.

@yegle
Copy link
Author

yegle commented Feb 26, 2015

Also thirdparty package candidate: https://code.google.com/p/getopt/

@mattn
Copy link

mattn commented Feb 27, 2015

+1

@mattn
Copy link

mattn commented Feb 27, 2015

I do always

$ ls -la
$ rm -rf ...

etc...

@yegle
Copy link
Author

yegle commented Feb 27, 2015

I've played and tested https://github.com/ogier/pflag This is a good drop-in replacement to Go's flag package (e.g. just change the import path and everything works fine). But it lacks some feature if we want to use it to simulate all coreutils flag behaviour.

One notable things that pflag can't do is the optional argument for non-bool flags. The example is ls --color which means ls --color=always. This is a flag.String in pflag, but you'll have to supply a value for such a flag.

I've reported this issue ogier/pflag#16 but I don't think there's an easy fix for the problem.

Moving on to test the other packages.

@abramisola
Copy link
Owner

Keeping in the spirit of the project, we won't be using third party services for any of the files at this point.

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

No branches or pull requests

3 participants