docopt / docopt.go

A command-line arguments parser that will make you smile.
http://docopt.org/
MIT License
1.43k stars 108 forks source link

protect real git binary by renaming examples #44

Closed mcandre closed 6 years ago

mcandre commented 7 years ago

Some example source files such as git.go share names with common command line utilities, such as the real git. This has the unfortunate consequence that users attempting to make use of docopt.go receive a fake git binary in $GOPATH/bin that can accidentally override the real git. Especially if the position of $GOPATH/bin in $PATH occurs before the directory of the real git binary appears in $PATH. This happens because the source files in the examples/ directory are automatically built and installed by the standard go tool, such as with go get github.com/docopt/docopt.go.

Go users may wish to reposition $GOPATH/bin in their $PATH configuration, to ensure that non-Go binaries take precedence. This allows docopt.go to be used without conflicting with the regular git binary.

However, for some users a configuration with $GOPATH/bin earlier in $PATH may actually be desirable, such as when overriding system binaries with custom binaries. That's okay, we can resolve this situation as well, by renaming the git.go source file to fakegit.go. This rename allows the real git binary to continue functioning with docopt.go installed, regardless of the user's choice of ordering in their $PATH.

Some later commit could even exclude the example/ binaries from being installed to $GOPATH/bin, by refactoring the examples in terms of ..._test.go files, a common Go unit testing convention.

DanielOaks commented 7 years ago

Yes please, the git issue specifically tends to cause issues for my new Go installs 'til I remember to delete the right binary in the gopath.

mcandre commented 7 years ago

Interesting, the CI build appears to have trouble downloading the vet tool. Looks like the old vet tool has been deprecated in favor of the go vet tool now built into Go.

Vet update:

https://github.com/hashicorp/vault/issues/1310

Trace:

https://travis-ci.org/docopt/docopt.go/jobs/241851803

coveralls commented 7 years ago

Coverage Status

Coverage increased (+2.6%) to 89.904% when pulling a3199bb46d206ad2210807e23193b9e4a68c56bd on mcandre:protect-real-git-binary into 784ddc588536785e7299f7272f39101f7faccc3f on docopt:master.

mcandre commented 7 years ago

Rockin'! Dropping the go get for the old vet tool helps the build out.

There's also an error with golint, which now requires Go 1.6 or later.

Source:

https://github.com/golang/lint#installation

However, Travis CI is configured to test docopt.go against Go 1.4, 1.5, and tip. Fortunately, we have several options of resolving this conflict!

coveralls commented 7 years ago

Coverage Status

Coverage increased (+2.6%) to 89.904% when pulling 0e275d372a48861d2e6c51429ac1defb2f35d604 on mcandre:protect-real-git-binary into 784ddc588536785e7299f7272f39101f7faccc3f on docopt:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+2.6%) to 89.904% when pulling 65b50539475def054b4a44daf2fe9dd47131471f on mcandre:protect-real-git-binary into 784ddc588536785e7299f7272f39101f7faccc3f on docopt:master.

ghostsquad commented 6 years ago

Why hasn't this been merged yet?? @kbatten @mboersma

DanielOaks commented 6 years ago

For what it's worth I'm not sure whether this package is still maintained, based on the activity 'n' times and all. Maybe time to find a new maintainer to take over the package? For what it's worth it looks like @aciddiviner's fork here is the most maintained of the bunch.

ghostsquad commented 6 years ago

@DanielOaks It seems it hasn't. It's a real shame. I did look at his fork. I filed an issue there to see if I can get some traction.

mboersma commented 6 years ago

@ghostsquad thanks for nudge, it's merged now. I apologize for being AWOL--I'll try to keep better track of contributions and notifications.

ghostsquad commented 6 years ago

@mboersma totally welcome. I love Docopt, used to use it a bunch in Python, and now I'm learning GoLang. Happy to see an implementation, sad to see some open issues and PRs and no updates in a couple years. Do you need help maintaining?

mboersma commented 6 years ago

@ghostsquad same here--loved docopt in python, and I actually had a case where we were porting a docopt CLI from Python to Go, so it was amazing to have docopt.go work the same way.

I would welcome any help maintaining docopt.go.