_**( Put the version of urfave/cli that you are using here )**_
## Checklist
* [ ] Are you running the latest v1 release? The list of releases is [here](https://github.com/urfave/cli/releases).
* [ ] Did you check the manual for your release? The v1 manual is [here](https://github.com/urfave/cli/blob/master/docs/v1/manual.md)
* [ ] Did you perform a search about this problem? Here's the [Github guide](https://help.github.com/en/github/managing-your-work-on-github/using-search-to-filter-issues-and-pull-requests) about searching.
- [ ] Are you running the latest v1 release? The list of releases is [here](https://github.com/urfave/cli/releases).
- [ ] Did you check the manual for your release? The v1 manual is [here](https://github.com/urfave/cli/blob/main/docs/v1/manual.md).
- [ ] Did you perform a search about this problem? Here's the [Github guide](https://help.github.com/en/github/managing-your-work-on-github/using-search-to-filter-issues-and-pull-requests) about searching.
## Dependency Management
- [ ] My project is using go modules.
- [ ] My project is using vendoring.
- [ ] My project is automatically downloading the latest version.
- [ ] I am unsure of what my dependency management setup is.
<!--
Delete any of the following that do not apply:
-->
- My project is using go modules.
- My project is using vendoring.
- My project is automatically downloading the latest version.
- I am unsure of what my dependency management setup is.
## Describe the bug
@ -34,23 +38,30 @@ Describe the steps or code required to reproduce the behavior
## Observed behavior
What did you see happen immediately after the reproduction steps above?
What did you see happen immediately after the reproduction steps
above?
## Expected behavior
What would you have expected to happen immediately after the reproduction steps above?
What would you have expected to happen immediately after the
reproduction steps above?
## Additional context
Add any other context about the problem here.
If the issue relates to a specific open source Github repo, please link that repo here.
If the issue relates to a specific open source Github repo, please
link that repo here.
If you can reproduce this issue with a public CI system, please link a failing build here.
If you can reproduce this issue with a public CI system, please
link a failing build here.
## Want to fix this yourself?
We'd love to have more contributors on this project! If the fix for this bug is easily explained and very small, free free to create a pull request for it. You'll want to base the PR off the `v1` branch, all `v1` bug fix releases will be made from that branch.
We'd love to have more contributors on this project! If the fix for
this bug is easily explained and very small, free free to create a
pull request for it. You'll want to base the PR off the `v1`
branch, all `v1` bug fix releases will be made from that branch.
_**( Put the version of urfave/cli that you are using here )**_
## Checklist
* [ ] Are you running the latest v2 release? The list of releases is [here](https://github.com/urfave/cli/releases).
* [ ] Did you check the manual for your release? The v2 manual is [here](https://github.com/urfave/cli/blob/master/docs/v2/manual.md)
* [ ] Did you perform a search about this problem? Here's the [Github guide](https://help.github.com/en/github/managing-your-work-on-github/using-search-to-filter-issues-and-pull-requests) about searching.
- [ ] Are you running the latest v2 release? The list of releases is [here](https://github.com/urfave/cli/releases).
- [ ] Did you check the manual for your release? The v2 manual is [here](https://github.com/urfave/cli/blob/main/docs/v2/manual.md)
- [ ] Did you perform a search about this problem? Here's the [Github guide](https://help.github.com/en/github/managing-your-work-on-github/using-search-to-filter-issues-and-pull-requests) about searching.
## Dependency Management
- [ ] My project is using go modules.
- [ ] My project is using vendoring.
- [ ] My project is automatically downloading the latest version.
- [ ] I am unsure of what my dependency management setup is.
<!--
Delete any of the following that do not apply:
-->
- My project is using go modules.
- My project is using vendoring.
- My project is automatically downloading the latest version.
- I am unsure of what my dependency management setup is.
## Describe the bug
@ -34,23 +38,30 @@ Describe the steps or code required to reproduce the behavior
## Observed behavior
What did you see happen immediately after the reproduction steps above?
What did you see happen immediately after the reproduction steps
above?
## Expected behavior
What would you have expected to happen immediately after the reproduction steps above?
What would you have expected to happen immediately after the
reproduction steps above?
## Additional context
Add any other context about the problem here.
If the issue relates to a specific open source Github repo, please link that repo here.
If the issue relates to a specific open source Github repo, please
link that repo here.
If you can reproduce this issue with a public CI system, please link a failing build here.
If you can reproduce this issue with a public CI system, please
link a failing build here.
## Want to fix this yourself?
We'd love to have more contributors on this project! If the fix for this bug is easily explained and very small, free free to create a pull request for it.
We'd love to have more contributors on this project! If the fix for
this bug is easily explained and very small, free free to create a
title: 'v2 feature: ( your feature title goes here )'
title: 'your feature title goes here'
labels: 'type/feature, area/v2, status/triage'
assignees: ''
@ -10,16 +10,19 @@ assignees: ''
## Checklist
* [ ] Are you running the latest v2 release? The list of releases is [here](https://github.com/urfave/cli/releases).
* [ ] Did you check the manual for your release? The v2 manual is [here](https://github.com/urfave/cli/blob/master/docs/v2/manual.md)
* [ ] Did you check the manual for your release? The v2 manual is [here](https://github.com/urfave/cli/blob/main/docs/v2/manual.md).
* [ ] Did you perform a search about this feature? Here's the [Github guide](https://help.github.com/en/github/managing-your-work-on-github/using-search-to-filter-issues-and-pull-requests) about searching.
## What problem does this solve?
A clear and concise description of what problem this feature would solve. For example:
- needing to type out the full flag name takes a long time, so I would like to suggest adding auto-complete
- I use (osx, windows, linux) and would like support for (some existing feature) to be extended to my platform
- the terminal output for a particular error case is confusing, and I think it could be improved
- needing to type out the full flag name takes a long time, so I
would like to suggest adding auto-complete
- I use (osx, windows, linux) and would like support for (some
existing feature) to be extended to my platform
- the terminal output for a particular error case is confusing, and
I think it could be improved
## Solution description
@ -27,4 +30,5 @@ A detailed description of what you want to happen.
## Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
A clear and concise description of any alternative solutions or
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
@ -12,7 +12,7 @@ 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`.
Usage documentation exists for each major version. Don't know what version you're on? You're probably using the version from the `main` branch, which is currently `v2`.
@ -30,7 +30,7 @@ Go Modules are required when using this package. [See the go blog guide on using
### Using `v2` releases
```
$ GO111MODULE=on go get github.com/urfave/cli/v2
$ go get github.com/urfave/cli/v2
```
```go
@ -44,7 +44,7 @@ import (
### Using `v1` releases
```
$ GO111MODULE=on go get github.com/urfave/cli
$ go get github.com/urfave/cli
```
```go
@ -67,4 +67,4 @@ export PATH=$PATH:$GOPATH/bin
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](https://github.com/urfave/cli/blob/master/.github/workflows/cli.yml).
builds. To see our currently supported go versions and platforms, look at the [./.github/workflows/cli.yml](https://github.com/urfave/cli/blob/main/.github/workflows/cli.yml).
@ -53,7 +56,7 @@ Check each file for this and make the change.
Shell command to find them all: `fgrep -rl github.com/urfave/cli *`
# Flag aliases are done differently.
# Flag aliases are done differently
Change `Name: "foo, f"` to `Name: "foo", Aliases: []string{"f"}`
@ -181,6 +184,52 @@ Compiler messages you might see:
cannot use c (type *cli.Command) as type cli.Command in append
```
# GlobalString, GlobalBool and its likes are deprecated
Use simply `String` instead of `GlobalString`, `Bool` instead of `GlobalBool`
# BoolTFlag and BoolT are deprecated
BoolTFlag was a Bool Flag with its default value set to true and BoolT was used to find any BoolTFlag used locally, so both are deprecated.
* OLD:
```go
cli.BoolTFlag{
Name: FlagName,
Usage: FlagUsage,
EnvVar: "FLAG_ENV_VAR",
}
```
* NEW:
```go
cli.BoolFlag{
Name: FlagName,
Value: true,
Usage: FlagUsage,
EnvVar: "FLAG_ENV_VAR",
}
```
# &cli.StringSlice{""} replaced with cli.NewStringSlice("")
Example:
* OLD:
```go
Value: &cli.StringSlice{""},
```
* NEW:
```go
Value: cli.NewStringSlice(""),
}
```
# Replace deprecated functions
`cli.NewExitError()` is deprecated. Use `cli.Exit()` instead. ([Staticcheck](https://staticcheck.io/) detects this automatically and recommends replacement code.)
# Everything else
Compile the code and work through any errors. Most should
There are a small set of breaking changes between v1 and v2.
Converting is relatively straightforward and typically takes less than
an hour. Specific steps are included in
[Migration Guide: v1 to v2](../migrate-v1-to-v2.md).
[Migration Guide: v1 to v2](../migrate-v1-to-v2.md). Also see the [pkg.go.dev docs](https://pkg.go.dev/github.com/urfave/cli/v2) for v2 API documentation.
## Getting Started
@ -425,15 +426,17 @@ import (
func main() {
app := &cli.App{
Flags: []cli.Flag{
&cli.StringFlag{
Name: "lang, l",
Value: "english",
Usage: "Language for the greeting",
},
&cli.StringFlag{
Name: "config, c",
Usage: "Load configuration from `FILE`",
},
&cli.StringFlag{
Name: "lang",
Aliases: []string{"l"},
Value: "english",
Usage: "Language for the greeting",
},
&cli.StringFlag{
Name: "config",
Aliases: []string{"c"},
Usage: "Load configuration from `FILE`",
},
},
Commands: []*cli.Command{
{
@ -511,7 +514,7 @@ func main() {
```
If `EnvVars` contains more than one string, the first environment variable that
resolves is used as the default.
resolves is used.
<!-- {
"args": ["--help"],
@ -570,7 +573,8 @@ func main() {
app.Flags = []cli.Flag {
&cli.StringFlag{
Name: "password, p",
Name: "password",
Aliases: []string{"p"},
Usage: "password for the mysql database",
FilePath: "/etc/mysql/password",
},
@ -623,7 +627,7 @@ given sources.
Here is a more complete sample of a command using YAML support:
{"foobar",newSetFloat64Slice(),&Float64SliceFlag{Name:"seconds",EnvVars:[]string{"SECONDS"}},`could not parse "\[\]float64{}" as float64 slice value for flag seconds: .*`},
{"1.2,2",newSetIntSlice(),&IntSliceFlag{Name:"seconds",EnvVars:[]string{"SECONDS"}},`could not parse "1.2,2" as int slice value for flag seconds: .*`},
{"foobar",newSetIntSlice(),&IntSliceFlag{Name:"seconds",EnvVars:[]string{"SECONDS"}},`could not parse "foobar" as int slice value for flag seconds: .*`},
@ -340,11 +349,11 @@ var stringSliceFlagTests = []struct {
expect(t,err,fmt.Errorf("invalid value \"2006-01-02T15:04:05Z\" for flag -time: parsing time \"2006-01-02T15:04:05Z\" as \"Jan 2, 2006 at 3:04pm (MST)\": cannot parse \"2006-01-02T15:04:05Z\" as \"Jan\""))