Go to file
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
.github Update pull_request_template.md 2020-03-30 16:27:15 -07:00
altsrc Simplified 2020-03-12 21:20:13 +03:00
autocomplete Fix zsh completion scripts 2020-02-10 01:43:36 +08:00
docs Merge pull request #1098 from TomOnTime/migration 2020-04-06 16:23:21 -07:00
internal move bounds 2020-02-29 14:04:21 -08:00
testdata Fix man page heading formatting 2020-01-15 08:51:07 +01:00
.flake8 Allow slightly longer lines in Python scripts 2017-02-14 21:17:32 -08:00
.gitignore add diffing 2020-02-29 14:00:26 -08:00
app_test.go add tests 2020-04-01 09:17:59 -04:00
app.go add tests 2020-04-01 09:17:59 -04:00
args.go add is set method to flag interface - refer #294 2019-09-15 18:46:52 +05:30
category.go amend comments 2019-12-12 21:29:09 +00:00
cli.go Merge master @1.22.1 with v2 2019-09-13 05:17:24 +05:30
CODE_OF_CONDUCT.md Merge master @1.22.1 with v2 2019-09-13 05:17:24 +05:30
command_test.go reduce stdout logs in tests 2019-12-29 17:00:19 +01:00
command.go Add HideHelpCommand 2020-03-06 16:17:24 +09:00
context_test.go add a fix 2019-12-24 08:55:31 -08:00
context.go remove unused code 2019-12-31 16:36:01 +01:00
docs_test.go Merge branch 'master' into github-actions-windows 2020-01-13 11:29:49 +05:30
docs.go Use VisibleFlags during doc generation 2019-12-19 08:38:43 -05:00
errors_test.go Update docs and tests around cli.Exit 2020-03-24 20:32:39 -04:00
errors.go Update docs and tests around cli.Exit 2020-03-24 20:32:39 -04:00
fish_test.go Merge master @1.22.1 with v2 2019-09-13 05:17:24 +05:30
fish.go Fix test cases for context, docs, errors, fish, flags and funcs 2019-09-15 11:01:20 +05:30
flag_bool.go refactor flag names - make it more explicitly 2019-12-29 08:58:12 +01:00
flag_duration.go refactor flag names - make it more explicitly 2019-12-29 08:58:12 +01:00
flag_float64_slice.go Fix possible panics in slice type assertion 2020-01-22 12:30:31 +01:00
flag_float64.go refactor flag names - make it more explicitly 2019-12-29 08:58:12 +01:00
flag_generic.go refactor flag names - make it more explicitly 2019-12-29 08:58:12 +01:00
flag_int64_slice.go Fix possible panics in slice type assertion 2020-01-22 12:30:31 +01:00
flag_int64.go refactor flag names - make it more explicitly 2019-12-29 08:58:12 +01:00
flag_int_slice.go Fix possible panics in slice type assertion 2020-01-22 12:30:31 +01:00
flag_int.go refactor flag names - make it more explicitly 2019-12-29 08:58:12 +01:00
flag_path.go refactor flag names - make it more explicitly 2019-12-29 08:58:12 +01:00
flag_string_slice.go Allow specifying a StringSlice destination for StringSliceFlag 2020-02-28 12:00:31 +00:00
flag_string.go refactor flag names - make it more explicitly 2019-12-29 08:58:12 +01:00
flag_test.go Save the temp dir before clearing environment variables 2020-04-14 07:55:17 +02:00
flag_timestamp.go refactor flag names - make it more explicitly 2019-12-29 08:58:12 +01:00
flag_uint64.go refactor flag names - make it more explicitly 2019-12-29 08:58:12 +01:00
flag_uint.go refactor flag names - make it more explicitly 2019-12-29 08:58:12 +01:00
flag.go Merge pull request #1083 from AkihiroSuda/hide-help-command 2020-03-06 07:46:02 -05:00
funcs.go Fix test cases for context, docs, errors, fish, flags and funcs 2019-09-15 11:01:20 +05:30
go.mod Merge master @1.22.1 with v2 2019-09-13 05:17:24 +05:30
go.sum Merge master @1.22.1 with v2 2019-09-13 05:17:24 +05:30
help_test.go Add HideHelpCommand 2020-03-06 16:17:24 +09:00
help.go fix some golint errors show in go report card 2019-12-12 21:24:43 +00:00
helpers_test.go remove unused code 2019-12-31 16:36:01 +01:00
LICENSE Update license text 2016-06-21 12:52:25 -04:00
parse.go revert testing change 2019-11-27 20:37:23 -08:00
README.md Link to migration guide 2020-04-04 06:09:14 -04:00
sort_test.go Merge master @1.22.1 with v2 2019-09-13 05:17:24 +05:30
sort.go Merge master @1.22.1 with v2 2019-09-13 05:17:24 +05:30
template.go fix description of subcommand more consistent 2020-01-28 17:31:02 +09:00

cli

GoDoc codebeat Go Report Card codecov

cli is a simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way.

Usage Documentation

Usage documentation exists for each major version. Don't know what version you're on? You're probably using the version from the master branch, which is currently v2.

Guides for migrating to newer versions:

Installation

Using this package requires a working Go environment. See the install instructions for Go.

Go Modules are required when using this package. See the go blog guide on using Go Modules.

Using v2 releases

$ GO111MODULE=on go get github.com/urfave/cli/v2
...
import (
  "github.com/urfave/cli/v2" // imports as package "cli"
)
...

Using v1 releases

$ GO111MODULE=on go get github.com/urfave/cli
...
import (
  "github.com/urfave/cli"
)
...

GOPATH

Make sure your PATH includes the $GOPATH/bin directory so your commands can be easily used:

export PATH=$PATH:$GOPATH/bin

Supported platforms

cli is tested against multiple versions of Go on Linux, and against the latest released version of Go on OS X and Windows. This project uses Github Actions for builds. To see our currently supported go versions and platforms, look at the ./.github/workflows/cli.yml.