Commit Graph

2033 Commits

Author SHA1 Message Date
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
lynn [they]
1b7e4e00c7
Merge pull request #1079 from urfave/binary-size
Add binary size bounds checking
2020-03-02 12:01:17 -08:00
Sascha Grunert
7742363500
Refactor '(default: …)' flag string into utility function
The usage of the `(default: …)` strings are a bit error prone so we now
refactor them into a dedicated helper function.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-03-02 13:05:45 +01:00
Lynn
a8a1ef04ee
move bounds 2020-02-29 14:04:21 -08:00
Lynn
bb4ec3bda2
docs 2020-02-29 14:03:02 -08:00
Lynn
1d4b01a6fc
move bounds 2020-02-29 14:02:03 -08:00
Lynn
3558c7f30c
add diffing 2020-02-29 14:00:26 -08:00