Merge pull request #1452 from urfave/shift-supported-go

Shift supported go versions
main
dearchap 2 years ago committed by GitHub
commit 87dedb6d77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,7 +15,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
go: [1.16.x, 1.17.x, 1.18.x] go: [1.17.x, 1.18.x, 1.19.x]
name: ${{ matrix.os }} @ Go ${{ matrix.go }} name: ${{ matrix.os }} @ Go ${{ matrix.go }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
@ -27,12 +27,16 @@ jobs:
- name: Set PATH - name: Set PATH
run: echo "${GITHUB_WORKSPACE}/.local/bin" >>"${GITHUB_PATH}" run: echo "${GITHUB_WORKSPACE}/.local/bin" >>"${GITHUB_PATH}"
- name: install goimports
if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
run: GOBIN=${PWD}/.local/bin go install golang.org/x/tools/cmd/goimports@latest
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: GOFMT Check - name: goimports check
if: matrix.go == '1.18.x' && matrix.os == 'ubuntu-latest' if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
run: test -z $(gofmt -l .) run: test -z $(goimports -l .)
- name: vet - name: vet
run: go run internal/build/build.go vet run: go run internal/build/build.go vet
@ -53,7 +57,7 @@ jobs:
run: go run internal/build/build.go -tags urfave_cli_no_docs check-binary-size run: go run internal/build/build.go -tags urfave_cli_no_docs check-binary-size
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
if: success() && matrix.go == '1.18.x' && matrix.os == 'ubuntu-latest' if: success() && matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v2 uses: codecov/codecov-action@v2
with: with:
fail_ci_if_error: true fail_ci_if_error: true
@ -65,7 +69,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@v3
with: with:
go-version: 1.18.x go-version: 1.19.x
- name: Use Node.js 16 - name: Use Node.js 16
uses: actions/setup-node@v3 uses: actions/setup-node@v3

10
.gitignore vendored

@ -1,11 +1,13 @@
*.coverprofile *.coverprofile
*.exe
*.orig *.orig
vendor .*envrc
.envrc
.idea .idea
internal/*/built-example
coverage.txt
/.local/ /.local/
/site/ /site/
coverage.txt
internal/*/built-example
vendor
/cmd/urfave-cli-genflags/urfave-cli-genflags /cmd/urfave-cli-genflags/urfave-cli-genflags
*.exe *.exe

@ -1,11 +1,13 @@
// Package cli provides a minimal framework for creating and organizing command line // Package cli provides a minimal framework for creating and organizing command line
// Go applications. cli is designed to be easy to understand and write, the most simple // Go applications. cli is designed to be easy to understand and write, the most simple
// cli application can be written as follows: // cli application can be written as follows:
//
// func main() { // func main() {
// (&cli.App{}).Run(os.Args) // (&cli.App{}).Run(os.Args)
// } // }
// //
// Of course this application does not do much, so let's make this an actual application: // Of course this application does not do much, so let's make this an actual application:
//
// func main() { // func main() {
// app := &cli.App{ // app := &cli.App{
// Name: "greet", // Name: "greet",

@ -64,8 +64,8 @@ GLOBAL OPTIONS:
COPYRIGHT: COPYRIGHT:
{{wrap .Copyright 3}}{{end}} {{wrap .Copyright 3}}{{end}}
` `
AppHelpTemplate is the text template for the Default help topic. cli.go uses AppHelpTemplate is the text template for the Default help topic. cli.go
text/template to render templates. You can render custom help text by uses text/template to render templates. You can render custom help text by
setting this variable. setting this variable.
var CommandHelpTemplate = `NAME: var CommandHelpTemplate = `NAME:
@ -201,9 +201,9 @@ func DefaultAppComplete(cCtx *Context)
func DefaultCompleteWithFlags(cmd *Command) func(cCtx *Context) func DefaultCompleteWithFlags(cmd *Command) func(cCtx *Context)
func FlagNames(name string, aliases []string) []string func FlagNames(name string, aliases []string) []string
func HandleAction(action interface{}, cCtx *Context) (err error) func HandleAction(action interface{}, cCtx *Context) (err error)
HandleAction attempts to figure out which Action signature was used. If it's HandleAction attempts to figure out which Action signature was used.
an ActionFunc or a func with the legacy signature for Action, the func is If it's an ActionFunc or a func with the legacy signature for Action,
run! the func is run!
func HandleExitCoder(err error) func HandleExitCoder(err error)
HandleExitCoder handles errors implementing ExitCoder by printing their HandleExitCoder handles errors implementing ExitCoder by printing their
@ -360,14 +360,14 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error)
to generate command-specific flags to generate command-specific flags
func (a *App) RunContext(ctx context.Context, arguments []string) (err error) func (a *App) RunContext(ctx context.Context, arguments []string) (err error)
RunContext is like Run except it takes a Context that will be passed to its RunContext is like Run except it takes a Context that will be passed to
commands and sub-commands. Through this, you can propagate timeouts and its commands and sub-commands. Through this, you can propagate timeouts and
cancellation requests cancellation requests
func (a *App) Setup() func (a *App) Setup()
Setup runs initialization code to ensure all data structures are ready for Setup runs initialization code to ensure all data structures are ready
`Run` or inspection prior to `Run`. It is internally called by `Run`, but for `Run` or inspection prior to `Run`. It is internally called by `Run`,
will return early if setup has already happened. but will return early if setup has already happened.
func (a *App) ToFishCompletion() (string, error) func (a *App) ToFishCompletion() (string, error)
ToFishCompletion creates a fish completion string for the `*App` The ToFishCompletion creates a fish completion string for the `*App` The
@ -799,9 +799,9 @@ func Exit(message interface{}, exitCode int) ExitCoder
Exit wraps a message and exit code into an error, which by default is Exit wraps a message and exit code into an error, which by default is
handled with a call to os.Exit during default error handling. handled with a call to os.Exit during default error handling.
This is the simplest way to trigger a non-zero exit code for an App without This is the simplest way to trigger a non-zero exit code for an App
having to call os.Exit manually. During testing, this behavior can be without having to call os.Exit manually. During testing, this behavior
avoided by overiding the ExitErrHandler function on an App or the can be avoided by overiding the ExitErrHandler function on an App or the
package-global OsExiter function. package-global OsExiter function.
func NewExitError(message interface{}, exitCode int) ExitCoder func NewExitError(message interface{}, exitCode int) ExitCoder
@ -1431,8 +1431,8 @@ type MultiInt64Flag = SliceFlag[*Int64SliceFlag, []int64, int64]
directly, as Value and/or Destination. See also SliceFlag. directly, as Value and/or Destination. See also SliceFlag.
type MultiIntFlag = SliceFlag[*IntSliceFlag, []int, int] type MultiIntFlag = SliceFlag[*IntSliceFlag, []int, int]
MultiIntFlag extends IntSliceFlag with support for using slices directly, as MultiIntFlag extends IntSliceFlag with support for using slices directly,
Value and/or Destination. See also SliceFlag. as Value and/or Destination. See also SliceFlag.
type MultiStringFlag = SliceFlag[*StringSliceFlag, []string, string] type MultiStringFlag = SliceFlag[*StringSliceFlag, []string, string]
MultiStringFlag extends StringSliceFlag with support for using slices MultiStringFlag extends StringSliceFlag with support for using slices
@ -1513,8 +1513,8 @@ type RequiredFlag interface {
IsRequired() bool IsRequired() bool
} }
RequiredFlag is an interface that allows us to mark flags as required it RequiredFlag is an interface that allows us to mark flags as required
allows flags required flags to be backwards compatible with the Flag it allows flags required flags to be backwards compatible with the Flag
interface interface
type Serializer interface { type Serializer interface {
@ -1527,9 +1527,9 @@ type SliceFlag[T SliceFlagTarget[E], S ~[]E, E any] struct {
Value S Value S
Destination *S Destination *S
} }
SliceFlag extends implementations like StringSliceFlag and IntSliceFlag with SliceFlag extends implementations like StringSliceFlag and IntSliceFlag
support for using slices directly, as Value and/or Destination. See also with support for using slices directly, as Value and/or Destination.
SliceFlagTarget, MultiStringFlag, MultiFloat64Flag, MultiInt64Flag, See also SliceFlagTarget, MultiStringFlag, MultiFloat64Flag, MultiInt64Flag,
MultiIntFlag. MultiIntFlag.
func (x *SliceFlag[T, S, E]) Apply(set *flag.FlagSet) error func (x *SliceFlag[T, S, E]) Apply(set *flag.FlagSet) error
@ -1986,9 +1986,9 @@ func InitInputSource(flags []cli.Flag, createInputSource func() (InputSourceCont
that are supported by the input source that are supported by the input source
func InitInputSourceWithContext(flags []cli.Flag, createInputSource func(cCtx *cli.Context) (InputSourceContext, error)) cli.BeforeFunc func InitInputSourceWithContext(flags []cli.Flag, createInputSource func(cCtx *cli.Context) (InputSourceContext, error)) cli.BeforeFunc
InitInputSourceWithContext is used to to setup an InputSourceContext on a InitInputSourceWithContext is used to to setup an InputSourceContext on
cli.Command Before method. It will create a new input source based on the a cli.Command Before method. It will create a new input source based on
func provided with potentially using existing cli.Context values to the func provided with potentially using existing cli.Context values to
initialize itself. If there is no error it will then apply the new input initialize itself. If there is no error it will then apply the new input
source to any flags that are supported by the input source source to any flags that are supported by the input source

@ -64,8 +64,8 @@ GLOBAL OPTIONS:
COPYRIGHT: COPYRIGHT:
{{wrap .Copyright 3}}{{end}} {{wrap .Copyright 3}}{{end}}
` `
AppHelpTemplate is the text template for the Default help topic. cli.go uses AppHelpTemplate is the text template for the Default help topic. cli.go
text/template to render templates. You can render custom help text by uses text/template to render templates. You can render custom help text by
setting this variable. setting this variable.
var CommandHelpTemplate = `NAME: var CommandHelpTemplate = `NAME:
@ -201,9 +201,9 @@ func DefaultAppComplete(cCtx *Context)
func DefaultCompleteWithFlags(cmd *Command) func(cCtx *Context) func DefaultCompleteWithFlags(cmd *Command) func(cCtx *Context)
func FlagNames(name string, aliases []string) []string func FlagNames(name string, aliases []string) []string
func HandleAction(action interface{}, cCtx *Context) (err error) func HandleAction(action interface{}, cCtx *Context) (err error)
HandleAction attempts to figure out which Action signature was used. If it's HandleAction attempts to figure out which Action signature was used.
an ActionFunc or a func with the legacy signature for Action, the func is If it's an ActionFunc or a func with the legacy signature for Action,
run! the func is run!
func HandleExitCoder(err error) func HandleExitCoder(err error)
HandleExitCoder handles errors implementing ExitCoder by printing their HandleExitCoder handles errors implementing ExitCoder by printing their
@ -360,14 +360,14 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error)
to generate command-specific flags to generate command-specific flags
func (a *App) RunContext(ctx context.Context, arguments []string) (err error) func (a *App) RunContext(ctx context.Context, arguments []string) (err error)
RunContext is like Run except it takes a Context that will be passed to its RunContext is like Run except it takes a Context that will be passed to
commands and sub-commands. Through this, you can propagate timeouts and its commands and sub-commands. Through this, you can propagate timeouts and
cancellation requests cancellation requests
func (a *App) Setup() func (a *App) Setup()
Setup runs initialization code to ensure all data structures are ready for Setup runs initialization code to ensure all data structures are ready
`Run` or inspection prior to `Run`. It is internally called by `Run`, but for `Run` or inspection prior to `Run`. It is internally called by `Run`,
will return early if setup has already happened. but will return early if setup has already happened.
func (a *App) ToFishCompletion() (string, error) func (a *App) ToFishCompletion() (string, error)
ToFishCompletion creates a fish completion string for the `*App` The ToFishCompletion creates a fish completion string for the `*App` The
@ -799,9 +799,9 @@ func Exit(message interface{}, exitCode int) ExitCoder
Exit wraps a message and exit code into an error, which by default is Exit wraps a message and exit code into an error, which by default is
handled with a call to os.Exit during default error handling. handled with a call to os.Exit during default error handling.
This is the simplest way to trigger a non-zero exit code for an App without This is the simplest way to trigger a non-zero exit code for an App
having to call os.Exit manually. During testing, this behavior can be without having to call os.Exit manually. During testing, this behavior
avoided by overiding the ExitErrHandler function on an App or the can be avoided by overiding the ExitErrHandler function on an App or the
package-global OsExiter function. package-global OsExiter function.
func NewExitError(message interface{}, exitCode int) ExitCoder func NewExitError(message interface{}, exitCode int) ExitCoder
@ -1431,8 +1431,8 @@ type MultiInt64Flag = SliceFlag[*Int64SliceFlag, []int64, int64]
directly, as Value and/or Destination. See also SliceFlag. directly, as Value and/or Destination. See also SliceFlag.
type MultiIntFlag = SliceFlag[*IntSliceFlag, []int, int] type MultiIntFlag = SliceFlag[*IntSliceFlag, []int, int]
MultiIntFlag extends IntSliceFlag with support for using slices directly, as MultiIntFlag extends IntSliceFlag with support for using slices directly,
Value and/or Destination. See also SliceFlag. as Value and/or Destination. See also SliceFlag.
type MultiStringFlag = SliceFlag[*StringSliceFlag, []string, string] type MultiStringFlag = SliceFlag[*StringSliceFlag, []string, string]
MultiStringFlag extends StringSliceFlag with support for using slices MultiStringFlag extends StringSliceFlag with support for using slices
@ -1513,8 +1513,8 @@ type RequiredFlag interface {
IsRequired() bool IsRequired() bool
} }
RequiredFlag is an interface that allows us to mark flags as required it RequiredFlag is an interface that allows us to mark flags as required
allows flags required flags to be backwards compatible with the Flag it allows flags required flags to be backwards compatible with the Flag
interface interface
type Serializer interface { type Serializer interface {
@ -1527,9 +1527,9 @@ type SliceFlag[T SliceFlagTarget[E], S ~[]E, E any] struct {
Value S Value S
Destination *S Destination *S
} }
SliceFlag extends implementations like StringSliceFlag and IntSliceFlag with SliceFlag extends implementations like StringSliceFlag and IntSliceFlag
support for using slices directly, as Value and/or Destination. See also with support for using slices directly, as Value and/or Destination.
SliceFlagTarget, MultiStringFlag, MultiFloat64Flag, MultiInt64Flag, See also SliceFlagTarget, MultiStringFlag, MultiFloat64Flag, MultiInt64Flag,
MultiIntFlag. MultiIntFlag.
func (x *SliceFlag[T, S, E]) Apply(set *flag.FlagSet) error func (x *SliceFlag[T, S, E]) Apply(set *flag.FlagSet) error
@ -1986,9 +1986,9 @@ func InitInputSource(flags []cli.Flag, createInputSource func() (InputSourceCont
that are supported by the input source that are supported by the input source
func InitInputSourceWithContext(flags []cli.Flag, createInputSource func(cCtx *cli.Context) (InputSourceContext, error)) cli.BeforeFunc func InitInputSourceWithContext(flags []cli.Flag, createInputSource func(cCtx *cli.Context) (InputSourceContext, error)) cli.BeforeFunc
InitInputSourceWithContext is used to to setup an InputSourceContext on a InitInputSourceWithContext is used to to setup an InputSourceContext on
cli.Command Before method. It will create a new input source based on the a cli.Command Before method. It will create a new input source based on
func provided with potentially using existing cli.Context values to the func provided with potentially using existing cli.Context values to
initialize itself. If there is no error it will then apply the new input initialize itself. If there is no error it will then apply the new input
source to any flags that are supported by the input source source to any flags that are supported by the input source

Loading…
Cancel
Save