Commit Graph

1989 Commits

Author SHA1 Message Date
Ole Petter
710c8f71c4
test(context): Added regression test for requiredFlagsError
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)
2020-05-02 19:50:03 +02:00
Sergey Goroshko
196b222a8b fix #1121(StringSliceFlag set default value into destination) 2020-05-01 23:06:09 +03:00
Robert Liebowitz
464c868816
Merge pull request #1117 from creekorful/harmonize-error-handling
Harmonize BeforeError handling
2020-04-28 06:33:12 -04:00
Aloïs Micard
c261e4dbd3
Harmonize BeforeError usage in Command#Run 2020-04-28 08:04:17 +02:00
Aloïs Micard
33744eb004
Harmonize BeforeError handling 2020-04-27 19:50:15 +02:00
lynn
4bb97e00e0
Merge pull request #1109 from mostynb/test_reset_entire_env
Reset the environment variables after each test that clears them
2020-04-24 18:30:38 -07:00
Mostyn Bramley-Moore
4853dd3144 Reset the environment variables after each test that clears them
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.
2020-04-15 08:32:07 +02:00
Robert Liebowitz
3b22cad8d7
Merge pull request #1107 from mostynb/test_environment_tempdir
Save the temp dir before clearing environment variables
2020-04-14 06:40:52 -04:00
Robert Liebowitz
3e069af0ca
Merge pull request #1106 from mostynb/windows_drive_letter
Don't assume a fixed windows drive letter in tests
2020-04-14 06:33:23 -04:00
Mostyn Bramley-Moore
8d907b5329 Save the temp dir before clearing environment variables
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.
2020-04-14 07:55:17 +02:00
Mostyn Bramley-Moore
9eb96e77a1 Don't assume a fixed windows drive letter in tests
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.
2020-04-14 07:42:42 +02:00
lynn [they]
7a390105cb
Merge pull request #1098 from TomOnTime/migration
Add a v1 => v2 migration guide
2020-04-06 16:23:21 -07:00
Tom Limoncelli
2f5b961b06 Link to migration guide 2020-04-04 06:13:16 -04:00
Tom Limoncelli
9fd9cd1117 Link to migration guide 2020-04-04 06:09:14 -04:00
lynn [they]
95b323fc6f
Merge pull request #1100 from Nokel81/set-err-writer
Set App.ErrWriter in App.Setup()
2020-04-01 20:48:17 -07:00
lynn [they]
51a22574bf
Merge pull request #1102 from urfave/lynncyrin-patch-1
Release 1.22.4
2020-04-01 11:32:32 -07:00
Sebastian Malton
fed64f3ad7 add tests 2020-04-01 09:17:59 -04:00
Tom Limoncelli
200fa41ab3 Revert v2/manual.md 2020-03-31 18:59:44 -04:00
Tom Limoncelli
be370eb485 Re-order items to be more logical. 2020-03-31 18:58:39 -04:00
Tom Limoncelli
84c98fac3e Move migration to a separate file.Move migration to a separate file 2020-03-31 18:54:05 -04:00
lynn [they]
f41aa2567f
Update CHANGELOG.md 2020-03-31 15:01:22 -07:00
lynn [they]
28789a9775
Update CHANGELOG.md 2020-03-31 15:00:40 -07:00
lynn [they]
fa64b8efd0
Merge pull request #1099 from urfave/lynncyrin-patch-1
Remove leading whitespace in PR template
2020-03-31 14:46:17 -07:00
Sebastian Malton
22b6dbaad3 Set App.ErrWriter in App.Setup()
- Defaults to os.Stderr
- Remove the App.errWriter() function since it is no longer needed
2020-03-31 10:43:36 -04:00
lynn [they]
3020108d13
Update pull_request_template.md 2020-03-30 16:27:15 -07:00
lynn [they]
39f9fbd723
Merge pull request #1086 from akramarenkov/fix-altsrc-nil-source-flag
Fix bug 'Unable to load file' in altsrc
2020-03-30 16:25:52 -07:00
Tom Limoncelli
dc7ae10a15 fixup! 2020-03-30 10:57:50 -04:00
Tom Limoncelli
caa97b585e Fix TOC 2020-03-29 11:29:34 -04:00
Tom Limoncelli
9faa4e4097 Fix TOC 2020-03-29 11:26:02 -04:00
Tom Limoncelli
6b3b21728c Fix TOC 2020-03-29 11:24:23 -04:00
Tom Limoncelli
228f1c9c58 fixup! 2020-03-29 11:15:13 -04:00
Tom Limoncelli
7a4368def7 fixup! 2020-03-29 11:11:03 -04:00
Tom Limoncelli
710df05119 Add a v1 => v2 migration guide 2020-03-29 11:02:05 -04:00
Robert Liebowitz
dd51d24ce6
Merge pull request #1091 from rliebz/document-exit-errors
Update docs and tests around cli.Exit
2020-03-25 17:52:14 -04:00
Robert Liebowitz
959cf9de8a Update docs and tests around cli.Exit
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
2020-03-24 20:32:39 -04:00
lynn [they]
1c4bb12e86
Merge pull request #1087 from l1905/master
fix typo in v2 manual.md demo code
2020-03-18 09:31:05 -07:00
litongxue
f7ef1e38d6 fix typo in v2 manual.md demo code 2020-03-18 14:32:57 +08:00
Aleksandr Kramarenko
8f64abd176 Simplified 2020-03-12 21:20:13 +03:00
lynn [they]
120c9eead1
Merge pull request #1084 from urfave/lynncyrin-patch-1
Release 2.2.0
2020-03-10 12:44:57 -07:00
lynn [they]
b4bc58ed8a
Merge pull request #1085 from urfave/lynncyrin-patch-2
go 1.14
2020-03-10 11:08:54 -07:00
Aleksandr Kramarenko
32dd20a85b Fix altsrc nil source flag 2020-03-09 13:34:05 +03:00
lynn [they]
526f019335
Update CHANGELOG.md 2020-03-09 01:37:39 -07:00
lynn [they]
2604b5e82d
Update CHANGELOG.md 2020-03-09 01:35:19 -07:00
lynn [they]
f4ec4f67b3
Update README.md 2020-03-09 01:14:51 -07:00
lynn [they]
d7919f0fdd
Update README.md 2020-03-09 01:13:18 -07:00
lynn [they]
97faf22319
Update cli.yml 2020-03-09 01:05:04 -07:00
lynn [they]
ff1566ff2b
Update CHANGELOG.md 2020-03-08 03:58:52 -07:00
Robert Liebowitz
d648edd48d
Merge pull request #1083 from AkihiroSuda/hide-help-command
Add HideHelpCommand
2020-03-06 07:46:02 -05:00
Akihiro Suda
75e7c526bd Add HideHelpCommand
While `HideHelp` hides both `help` command and `--help` flag, `HideHelpCommand`
only hides `help` command and leave `--help` flag as-is.

The behavior of `HideHelp` is untouched in this commit.

Fix #523
Replace #636

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-03-06 16:17:24 +09:00
Robert Liebowitz
3cc9946b2a
Merge pull request #1080 from saschagrunert/refactor-flag-default
Refactor '(default: …)' flag string into utility function
2020-03-05 08:19:39 -05:00