Repository: urfave/cli
Pull request #1654 (2023-01-22 19:38:35)

Update many v1 things
## What type of PR is this?

- cleanup

## What this PR does / why we need it:

including:
- testing on `windows-latest` in CI
- updating license year
- updating badges in README
- removing references to outdated v2 docs
- removing references to `GOPATH`
- removing appveyer config
- introducing stretchr/testify for comparison assertions
- replacing usage of `ioutil`
- updating all dependencies
- removing outdated version-specific test files


Patch:
diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml
index 26452b4..544ccfe 100644
--- a/.github/workflows/cli.yml
+++ b/.github/workflows/cli.yml
@@ -14,7 +14,7 @@ jobs:
   test:
     strategy:
       matrix:
-        os: [ubuntu-latest, macos-latest]
+        os: [ubuntu-latest, macos-latest, windows-latest]
         go: [1.18.x, 1.19.x]
     name: ${{ matrix.os }} @ Go ${{ matrix.go }}
     runs-on: ${{ matrix.os }}
diff --git a/.gitignore b/.gitignore
index 8df35c5..9d18120 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,5 @@ vendor
 /.local/
 /internal/
 /site/
+package.json
+package-lock.json
diff --git a/LICENSE b/LICENSE
index 42a597e..99d8559 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 MIT License
 
-Copyright (c) 2016 Jeremy Saenz & Contributors
+Copyright (c) 2023 Jeremy Saenz & Contributors
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 9c2cf85..c7dd62b 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,10 @@
 cli
 ===
 
-[![Build Status](https://travis-ci.org/urfave/cli.svg?branch=master)](https://travis-ci.org/urfave/cli)
-[![Windows Build Status](https://ci.appveyor.com/api/projects/status/rtgk5xufi932pb2v?svg=true)](https://ci.appveyor.com/project/urfave/cli)
-
-[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://godoc.org/github.com/urfave/cli)
-[![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-urfave-cli)
+[![Run Tests](https://github.com/urfave/cli/actions/workflows/cli.yml/badge.svg?branch=v1-maint)](https://github.com/urfave/cli/actions/workflows/cli.yml)
+[![Go Reference](https://pkg.go.dev/badge/github.com/urfave/cli/.svg)](https://pkg.go.dev/github.com/urfave/cli/)
 [![Go Report Card](https://goreportcard.com/badge/urfave/cli)](https://goreportcard.com/report/urfave/cli)
-[![codecov](https://codecov.io/gh/urfave/cli/branch/master/graph/badge.svg)](https://codecov.io/gh/urfave/cli)
+[![codecov](https://codecov.io/gh/urfave/cli/branch/v1-maint/graph/badge.svg)](https://codecov.io/gh/urfave/cli)
 
 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
@@ -15,29 +12,19 @@ applications in an expressive way.
 
 ## Usage Documentation
 
-Usage documentation exists for each major version
-
-- `v1` - [./docs/v1/manual.md](./docs/v1/manual.md)
-- `v2` - 🚧 documentation for `v2` is WIP 🚧
+Usage documentation for `v1` is available [at the docs
+site](https://cli.urfave.org/v1/getting-started/) or in-tree at
+[./docs/v1/manual.md](./docs/v1/manual.md)
 
 ## Installation
 
-Make sure you have a working Go environment.  Go version 1.10+ is supported.  [See
-the install instructions for Go](http://golang.org/doc/install.html).
-
-### GOPATH
-
-Make sure your `PATH` includes the `$GOPATH/bin` directory so your commands can
-be easily used:
-```
-export PATH=$PATH:$GOPATH/bin
-```
+Make sure you have a working Go environment. Go version 1.18+ is supported.
 
 ### 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.  For full details, see
-[`./.travis.yml`](./.travis.yml) and [`./appveyor.yml`](./appveyor.yml).
+cli is tested against multiple versions of Go on Linux, and against the latest released
+version of Go on OS X and Windows.  For full details, see
+[./.github/workflows/cli.yml](./.github/workflows/cli.yml).
 
 ### Build tags
 
@@ -62,19 +49,3 @@ import (
 )
 ...
 ```
-
-### Using `v2` releases
-
-**Warning**: `v2` is in a pre-release state.
-
-```
-$ go get github.com/urfave/cli.v2
-```
-
-```go
-...
-import (
-  "github.com/urfave/cli.v2" // imports as package "cli"
-)
-...
-```
diff --git a/altsrc/toml_file_loader.go b/altsrc/toml_file_loader.go
index 127693a..773ab57 100644
--- a/altsrc/toml_file_loader.go
+++ b/altsrc/toml_file_loader.go
@@ -1,8 +1,3 @@
-// Disabling building of toml support in cases where golang is 1.0 or 1.1
-// as the encoding library is not implemented or supported.
-
-// +build go1.2
-
 package altsrc
 
 import (
diff --git a/altsrc/yaml_file_loader.go b/altsrc/yaml_file_loader.go
index 2177c75..1ea1605 100644
--- a/altsrc/yaml_file_loader.go
+++ b/altsrc/yaml_file_loader.go
@@ -1,8 +1,3 @@
-// Disabling building of yaml support in cases where golang is 1.0 or 1.1
-// as the encoding library is not implemented or supported.
-
-// +build go1.2
-
 package altsrc
 
 import (
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 8ef2fea..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-version: "{build}"
-
-os: Windows Server 2016
-
-image: Visual Studio 2017
-
-clone_folder: c:\gopath\src\github.com\urfave\cli
-
-cache:
-  - node_modules
-
-environment:
-  GOPATH: C:\gopath
-  GOVERSION: 1.11.x
-  GO111MODULE: on
-  GOPROXY: https://proxy.golang.org
-
-install:
-  - set PATH=%GOPATH%\bin;C:\go\bin;%PATH%
-  - go version
-  - go env
-  - go get github.com/urfave/gfmrun/cmd/gfmrun
-  - go mod vendor
-
-build_script:
-  - go run build.go vet
-  - go run build.go test
-  - go run build.go gfmrun docs/v1/manual.md
diff --git a/build.go b/build.go
index 08cf7bb..f5561cd 100644
--- a/build.go
+++ b/build.go
@@ -1,4 +1,5 @@
-//+build ignore
+//go:build ignore
+// +build ignore
 
 package main
 
@@ -10,6 +11,7 @@ import (
 	"log"
 	"os"
 	"os/exec"
+	"runtime"
 	"strings"
 
 	"github.com/urfave/cli"
@@ -163,6 +165,11 @@ func GfmrunActionFunc(c *cli.Context) error {
 }
 
 func TocActionFunc(c *cli.Context) error {
+	if runtime.GOOS == "windows" {
+		log.Println("the toc command is not meant for windows")
+		return nil
+	}
+
 	filename := c.Args().Get(0)
 	if filename == "" {
 		filename = "README.md"
diff --git a/docs/v1/manual.md b/docs/v1/manual.md
index 8d04819..ec0b4a0 100644
--- a/docs/v1/manual.md
+++ b/docs/v1/manual.md
@@ -27,8 +27,8 @@ cli v1 manual
   * [Version Flag](#version-flag)
     + [Customization](#customization-2)
     + [Full API Example](#full-api-example)
-  * [Testing](#testing)
-  * [Migrating to V2](#migrating-to-v2)
+- [Testing](#testing)
+- [Migrating to V2](#migrating-to-v2)
 
 <!-- tocstop -->
 
diff --git a/go.mod b/go.mod
index 7d04d20..48129b6 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,8 @@ module github.com/urfave/cli
 go 1.11
 
 require (
-	github.com/BurntSushi/toml v0.3.1
-	github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d
-	gopkg.in/yaml.v2 v2.2.2
+	github.com/BurntSushi/toml v1.2.1
+	github.com/cpuguy83/go-md2man/v2 v2.0.2
+	github.com/stretchr/testify v1.8.1 // indirect
+	gopkg.in/yaml.v2 v2.4.0
 )
diff --git a/go.sum b/go.sum
index ef121ff..0bc5ad9 100644
--- a/go.sum
+++ b/go.sum
@@ -1,14 +1,25 @@
-github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
-github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
-github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
+github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
+github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
+github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
-github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
-github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
-github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
+github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
+github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
-gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=


Test patch:
diff --git a/altsrc/toml_command_test.go b/altsrc/toml_command_test.go
index 1d91d56..ffc1a9d 100644
--- a/altsrc/toml_command_test.go
+++ b/altsrc/toml_command_test.go
@@ -1,8 +1,3 @@
-// Disabling building of toml support in cases where golang is 1.0 or 1.1
-// as the encoding library is not implemented or supported.
-
-// +build go1.2
-
 package altsrc
 
 import (
diff --git a/altsrc/yaml_command_test.go b/altsrc/yaml_command_test.go
index 31f78ce..ad80ef3 100644
--- a/altsrc/yaml_command_test.go
+++ b/altsrc/yaml_command_test.go
@@ -1,8 +1,3 @@
-// Disabling building of yaml support in cases where golang is 1.0 or 1.1
-// as the encoding library is not implemented or supported.
-
-// +build go1.2
-
 package altsrc
 
 import (
diff --git a/docs_test.go b/docs_test.go
index f4bf1c5..f181df5 100644
--- a/docs_test.go
+++ b/docs_test.go
@@ -5,6 +5,8 @@ package cli
 
 import (
 	"testing"
+
+	"github.com/stretchr/testify/require"
 )
 
 func TestToMarkdownFull(t *testing.T) {
@@ -53,6 +55,6 @@ func TestToMan(t *testing.T) {
 	res, err := app.ToMan()
 
 	// Then
-	expect(t, err, nil)
+	require.Nil(t, err)
 	expectFileContent(t, "testdata/expected-doc-full.man", res)
 }
diff --git a/fish_test.go b/fish_test.go
index 62313f0..0fe9286 100644
--- a/fish_test.go
+++ b/fish_test.go
@@ -1,8 +1,11 @@
 package cli
 
 import (
-	"io/ioutil"
+	"os"
+	"strings"
 	"testing"
+
+	"github.com/stretchr/testify/require"
 )
 
 func testApp() *App {
@@ -66,9 +69,10 @@ func testApp() *App {
 }
 
 func expectFileContent(t *testing.T, file, expected string) {
-	data, err := ioutil.ReadFile(file)
-	expect(t, err, nil)
-	expect(t, string(data), expected)
+	data, err := os.ReadFile(file)
+	require.Nil(t, err)
+
+	require.Equal(t, strings.ReplaceAll(string(data), "\r\n", "\n"), expected)
 }
 
 func TestFishCompletion(t *testing.T) {
diff --git a/go116_test.go b/go116_test.go
deleted file mode 100644
index f6b5524..0000000
--- a/go116_test.go
+++ /dev/null
@@ -1,28 +0,0 @@
-//go:build !go1.17
-// +build !go1.17
-
-package cli
-
-import (
-	"bytes"
-	"errors"
-	"flag"
-	"testing"
-)
-
-func TestApp_RunAsSubCommandIncorrectUsage(t *testing.T) {
-	a := App{
-		Flags: []Flag{
-			StringFlag{Name: "--foo"},
-		},
-		Writer: bytes.NewBufferString(""),
-	}
-
-	set := flag.NewFlagSet("", flag.ContinueOnError)
-	_ = set.Parse([]string{"", "---foo"})
-	c := &Context{flagSet: set}
-
-	err := a.RunAsSubcommand(c)
-
-	expect(t, err, errors.New("bad flag syntax: ---foo"))
-}
diff --git a/go117_test.go b/go117_test.go
deleted file mode 100644
index f40ec4e..0000000
--- a/go117_test.go
+++ /dev/null
@@ -1,33 +0,0 @@
-//go:build go1.17
-// +build go1.17
-
-package cli
-
-import (
-	"bytes"
-	"flag"
-	"testing"
-)
-
-func TestApp_RunAsSubCommandIncorrectUsage(t *testing.T) {
-	a := App{
-		Flags: []Flag{
-			StringFlag{Name: "--foo"},
-		},
-		Writer: bytes.NewBufferString(""),
-	}
-
-	set := flag.NewFlagSet("", flag.ContinueOnError)
-	_ = set.Parse([]string{"", "---foo"})
-	c := &Context{flagSet: set}
-
-	// Go 1.17+ panics when invalid flag is given.
-	// Catch it here and consider the test passed.
-	defer func() {
-		if err := recover(); err == nil {
-			t.Fatal("expected error, got nothing")
-		}
-	}()
-
-	_ = a.RunAsSubcommand(c)
-}
diff --git a/helpers_unix_test.go b/helpers_unix_test.go
index ae27fc5..207925c 100644
--- a/helpers_unix_test.go
+++ b/helpers_unix_test.go
@@ -1,3 +1,4 @@
+//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
 // +build darwin dragonfly freebsd linux netbsd openbsd solaris
 
 package cli
diff --git a/testdata/expected-doc-full.man b/testdata/expected-doc-full.man
index 5190698..ce75939 100644
--- a/testdata/expected-doc-full.man
+++ b/testdata/expected-doc-full.man
@@ -5,7 +5,7 @@
 
 .SH NAME
 .PP
-greet \- Some app
+greet - Some app
 
 
 .SH SYNOPSIS
@@ -16,9 +16,9 @@ greet
 .RS
 
 .nf
-[\-\-another\-flag|\-b]
-[\-\-flag|\-\-fl|\-f]=[value]
-[\-\-socket|\-s]=[value]
+[--another-flag|-b]
+[--flag|--fl|-f]=[value]
+[--socket|-s]=[value]
 
 .fi
 .RE
@@ -26,7 +26,7 @@ greet
 
 .SH DESCRIPTION
 .PP
-app [first\_arg] [second\_arg]
+app [first_arg] [second_arg]
 
 .PP
 \fBUsage\fP:
@@ -43,13 +43,13 @@ greet [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...]
 
 .SH GLOBAL OPTIONS
 .PP
-\fB\-\-another\-flag, \-b\fP: another usage text
+\fB--another-flag, -b\fP: another usage text
 
 .PP
-\fB\-\-flag, \-\-fl, \-f\fP="":
+\fB--flag, --fl, -f\fP="":
 
 .PP
-\fB\-\-socket, \-s\fP="": some 'usage' text (default: value)
+\fB--socket, -s\fP="": some 'usage' text (default: value)
 
 
 .SH COMMANDS
@@ -58,23 +58,23 @@ greet [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...]
 another usage test
 
 .PP
-\fB\-\-another\-flag, \-b\fP: another usage text
+\fB--another-flag, -b\fP: another usage text
 
 .PP
-\fB\-\-flag, \-\-fl, \-f\fP="":
+\fB--flag, --fl, -f\fP="":
 
-.SS sub\-config, s, ss
+.SS sub-config, s, ss
 .PP
 another usage test
 
 .PP
-\fB\-\-sub\-command\-flag, \-s\fP: some usage text
+\fB--sub-command-flag, -s\fP: some usage text
 
 .PP
-\fB\-\-sub\-flag, \-\-sub\-fl, \-s\fP="":
+\fB--sub-flag, --sub-fl, -s\fP="":
 
 .SH info, i, in
 .PP
 retrieve generic information
 
-.SH some\-command
\ No newline at end of file
+.SH some-command
\ No newline at end of file