From 3dbbd5cf67fc9eeb88da7cc77a633641a0da93b3 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 1 Oct 2022 09:27:29 -0400 Subject: [PATCH] Porting #1452 to v3 --- .github/workflows/cli.yml | 16 ++++++++++------ .gitignore | 13 +++++++------ cli.go | 29 +++++++++++++++-------------- godoc-current.txt | 26 +++++++++++++------------- 4 files changed, 45 insertions(+), 39 deletions(-) diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml index 0a3e7c3685..09c501e4db 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/cli.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - go: [1.18.x] + go: [1.18.x, 1.19.x] name: ${{ matrix.os }} @ Go ${{ matrix.go }} runs-on: ${{ matrix.os }} steps: @@ -30,12 +30,16 @@ jobs: - name: Set 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 uses: actions/checkout@v3 - - name: GOFMT Check - if: matrix.go == '1.18.x' && matrix.os == 'ubuntu-latest' - run: test -z $(gofmt -l .) + - name: goimports Check + if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest' + run: test -z $(goimports -l .) - name: vet run: go run internal/build/build.go vet @@ -56,7 +60,7 @@ jobs: run: go run internal/build/build.go -tags urfave_cli_no_docs check-binary-size - 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 with: fail_ci_if_error: true @@ -68,7 +72,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18.x + go-version: 1.19.x - name: Use Node.js 16 uses: actions/setup-node@v3 diff --git a/.gitignore b/.gitignore index 4296f6c7a1..3c6768f8c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,12 @@ *.coverprofile +*.exe *.orig -vendor +.*envrc +.envrc .idea -internal/*/built-example -coverage.txt /.local/ -/site/ /cmd/urfave-cli-genflags/urfave-cli-genflags - -*.exe +/site/ +coverage.txt +internal/*/built-example +vendor diff --git a/cli.go b/cli.go index 8540dad3e2..b3ae43d197 100644 --- a/cli.go +++ b/cli.go @@ -1,23 +1,24 @@ // 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 // cli application can be written as follows: -// func main() { -// (&cli.App{}).Run(os.Args) -// } +// +// func main() { +// (&cli.App{}).Run(os.Args) +// } // // Of course this application does not do much, so let's make this an actual application: -// func main() { -// app := &cli.App{ -// Name: "greet", -// Usage: "say a greeting", -// Action: func(c *cli.Context) error { -// fmt.Println("Greetings") -// return nil -// }, -// } +// func main() { +// app := &cli.App{ +// Name: "greet", +// Usage: "say a greeting", +// Action: func(c *cli.Context) error { +// fmt.Println("Greetings") +// return nil +// }, +// } // -// app.Run(os.Args) -// } +// app.Run(os.Args) +// } package cli //go:generate go run cmd/urfave-cli-genflags/main.go diff --git a/godoc-current.txt b/godoc-current.txt index c35428ebc1..25343c8967 100644 --- a/godoc-current.txt +++ b/godoc-current.txt @@ -5,24 +5,24 @@ line Go applications. cli is designed to be easy to understand and write, the most simple cli application can be written as follows: 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: - func main() { - app := &cli.App{ - Name: "greet", - Usage: "say a greeting", - Action: func(c *cli.Context) error { - fmt.Println("Greetings") - return nil - }, - } - - app.Run(os.Args) - } + func main() { + app := &cli.App{ + Name: "greet", + Usage: "say a greeting", + Action: func(c *cli.Context) error { + fmt.Println("Greetings") + return nil + }, + } + + app.Run(os.Args) + } VARIABLES