This will simply list the files in the current directory if there are no
auto-completion options available.
With this change, the zsh auto-completion will align with the functionality in
the bash auto-completion file provided.
New functionality: https://asciinema.org/a/EAYRIEVGTGNSS2gCGwSJ4Zw1i
Old functionality: https://asciinema.org/a/BfOZz4BHUGwjXMFptbmDHZocH
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
StringSliceFlag needs to be a pointer, and not a struct. Also formatted the test.
See: https://github.com/urfave/cli/pull/1126 for a description of the regression
tested for.
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
This adds a test verifying that the requiredFlagsError does contain the long
option of the missing flag, instead of the short option and a space, which was
the old behaviour.
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
(cherry picked from commit f842187ebb32ee7d5109783d02fe9902b68ee54e)
Instead of just resetting the temp dir, let's reset all environment
variables.
Environment variables are a pain for testing. A more reliable solution
would be to refactor all functions that read from the environment to
take the environment as an explicit argument, and then provide a
consistent environment during testing. But that would be a significantly
larger change than this one.
Related to #1105.
In some windows setups, os.TempDir() will return something like
"C:\WINDOWS" if none of the expected environment variables (TMP, TEMP,
USERPROFILE) are set, and then functions that try to create temporary
files or directories will fail since this is not writable.
Several tests in flag_test.go clear the environment and then set a small
number of specific environment variables for the test, triggering the
following error in TestFlagFromFile when I run `go test ./...` on a new
windows machine:
flag_test.go:1667: open C:\WINDOWS\urfave_cli_test851254863: Access is denied.
To work around this, we can check the temp directory before calling
os.Clearenv() and use that directory explcitly in functions that
take the temp directory.
This fixes part of #1105.
Prior to this change, this test was failing for me on a new windows
machine, with mismatching drive letters:
helpers_test.go:20: (C:/Users/Foo Bar/cli/altsrc/flag_test.go:195) Expected C:\path\to\source\hello (type string) - Got D:\path\to\source\hello (type string)
Rather than hard-coding the drive letter in the expected path, we can
expect the filepath.Abs'ed version.
This should fix part of #1105.
Some of the docs were lacking or incomplete concerning how to properly
use cli.Exit, cli.HandleExitCoder, and the ExitErrHandler field on cli.App.
This change aims to clarify the usage of those pieces.
I also noticed that we have two identical functions now: cli.Exit and
cli.NewExitError. Since the latter seems to be more recent and less well
documented, I went ahead and marked it as deprecated so that we can keep
our public interface small.
Also added a missing test case for behavior that's been around a while
but was not documented or tested.
Related: #1089