Prevent the Go command completion from jumbling up the shell prompt on
errors by setting the Writer of the standard lib default log.Logger to
ioutil.Discard unless the system environment variable `GOCOMP_VERBOSE`
has been explicitly set to "1" (e.g. for debugging purposes).
Fixes#139
* complete: test capturing Complete() output
Implement an Example test to demonstrate capturing the output
of Complete(), which is crucial for integration tests.
* complete: do not hard-code the I/O streams at the package initialization
Instead of defining the input/output streams as unexported global vars
that only get their values assigned to once, at the very initialization
of the package, use the values that `os.Stdin` and `os.Stdout` have at
the particular moment on every `complete.Complete()` call.
Fix#137
* complete: capture and discard output in TestComplete
Restore earlier behavior using proper stream redirection this time.
* complete: output capturing example: define things in the package scope
Define the `stringLookup` func type and `promptEnv` func in the package
scope instead of the `ExampleComplete_outputCapturing` test.
* complete: rename the `stringLookup` func type to `getEnvFn`
Ensure that the components of the `testing` package that rely on calling
`os.Exit` remain functional and any test failures are actually reported
back after the `monkey.Patch` in the `gocomplete.Example` test.
Fix#135
Some shells (inexplicably) occasionally have a COMP_POINT that is greater than the COMP_LINE size. When that happens completion should be based on length of the COMP_LINE to avoid an out of bounds error.
See the original hack fix here: https://github.com/chriswalz/bit/blob/master/cmd/bitcomplete.go on line 39