Skip to content

Commit

Permalink
Merge pull request #1907 from urfave/tidy-go-mod
Browse files Browse the repository at this point in the history
Run go mod tidy
  • Loading branch information
meatballhat committed May 5, 2024
2 parents 84cb04e + 9ee5837 commit 817dcbc
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ jobs:
uses: actions/checkout@v4

- run: make ensure-gfmrun

- run: make gfmrun
env:
FLAGS: --walk docs/v3/

- run: make diffcheck

publish:
Expand Down
16 changes: 16 additions & 0 deletions docs/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module github.com/urfave/cli/docs/v3

go 1.18

replace github.com/urfave/cli/v3 => ../

require (
github.com/urfave/cli-altsrc/v3 v3.0.0-alpha2
github.com/urfave/cli/v3 v3.0.0-alpha9
)

require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/stretchr/testify v1.9.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
14 changes: 14 additions & 0 deletions docs/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
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/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli-altsrc/v3 v3.0.0-alpha2 h1:j4SaBpPB8++L0c0KuTnz/Yus3UQoWJ54hQjhIMW8rCM=
github.com/urfave/cli-altsrc/v3 v3.0.0-alpha2/go.mod h1:Q79oyIY/z4jtzIrKEK6MUeWC7/szGr46x4QdOaOAIWc=
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.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
9 changes: 9 additions & 0 deletions docs/package.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Package docs is an empty shell! This file is *only* meant to capture the dependencies
// required by the `gfmrun` documentation tests.

package docs

import (
_ "github.com/urfave/cli-altsrc/v3"
_ "github.com/urfave/cli/v3"
)
9 changes: 4 additions & 5 deletions docs/v3/examples/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,18 +520,18 @@ Here is a more complete sample of a command using YAML support:
package main

import (
"context"
"fmt"
"os"
"context"

altsrc "github.com/urfave/cli-altsrc/v3"
"github.com/urfave/cli/v3"
"github.com/urfave/cli-altsrc/v3"
)

func main() {
flags := []cli.Flag{
&cli.IntFlag{
Name: "test",
Name: "test",
Sources: altsrc.YAML("key", "/path/to/file"),
},
&cli.StringFlag{Name: "load"},
Expand All @@ -542,8 +542,7 @@ func main() {
fmt.Println("--test value.*default: 0")
return nil
},
//Before: altsrc.InitInputSourceWithContext(flags, altsrc.NewYamlSourceFromFlagFunc("load")),
Flags: flags,
Flags: flags,
}

cmd.Run(context.Background(), os.Args)
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ go 1.18
require github.com/stretchr/testify v1.8.4

require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/urfave/cli-altsrc/v3 v3.0.0-alpha2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
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/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/urfave/cli-altsrc/v3 v3.0.0-alpha2 h1:j4SaBpPB8++L0c0KuTnz/Yus3UQoWJ54hQjhIMW8rCM=
github.com/urfave/cli-altsrc/v3 v3.0.0-alpha2/go.mod h1:Q79oyIY/z4jtzIrKEK6MUeWC7/szGr46x4QdOaOAIWc=
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.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
48 changes: 24 additions & 24 deletions internal/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (
)

func main() {
top, err := func() (string, error) {
topDir, err := func() (string, error) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()

Expand Down Expand Up @@ -148,8 +148,8 @@ func main() {
Usage: "set build tags",
},
&cli.StringFlag{
Name: "top",
Value: top,
Name: "top-dir",
Value: topDir,
},
&cli.StringSliceFlag{
Name: "packages",
Expand All @@ -175,7 +175,7 @@ func sh(ctx context.Context, exe string, args ...string) (string, error) {

func topRunAction(arg string, args ...string) cli.ActionFunc {
return func(ctx context.Context, cmd *cli.Command) error {
if err := os.Chdir(cmd.String("top")); err != nil {
if err := os.Chdir(cmd.String("top-dir")); err != nil {
return err
}

Expand Down Expand Up @@ -232,7 +232,7 @@ func downloadFile(src, dest string, dirPerm, perm os.FileMode) error {
}

func VetActionFunc(ctx context.Context, cmd *cli.Command) error {
return runCmd(ctx, "go", "vet", cmd.String("top")+"/...")
return runCmd(ctx, "go", "vet", cmd.String("top-dir")+"/...")
}

func TestActionFunc(ctx context.Context, cmd *cli.Command) error {
Expand Down Expand Up @@ -293,7 +293,7 @@ func testCleanup(packages []string) error {
}

func GfmrunActionFunc(ctx context.Context, cmd *cli.Command) error {
top := cmd.String("top")
docsDir := filepath.Join(cmd.String("top-dir"), "docs")

bash, err := exec.LookPath("bash")
if err != nil {
Expand All @@ -318,7 +318,7 @@ func GfmrunActionFunc(ctx context.Context, cmd *cli.Command) error {

fmt.Fprintf(cmd.ErrWriter, "# ---> workspace/TMPDIR is %q\n", tmpDir)

if err := runCmd(ctx, "go", "work", "init", top); err != nil {
if err := runCmd(ctx, "go", "work", "init", docsDir); err != nil {
return err
}

Expand Down Expand Up @@ -489,22 +489,22 @@ func checkBinarySizeActionFunc(ctx context.Context, cmd *cli.Command) (err error
}

func GenerateActionFunc(ctx context.Context, cmd *cli.Command) error {
top := cmd.String("top")
topDir := cmd.String("top-dir")

cliDocs, err := sh(ctx, "go", "doc", "-all", top)
cliDocs, err := sh(ctx, "go", "doc", "-all", topDir)
if err != nil {
return err
}

return os.WriteFile(
filepath.Join(top, "godoc-current.txt"),
filepath.Join(topDir, "godoc-current.txt"),
[]byte(cliDocs),
0o644,
)
}

func DiffCheckActionFunc(ctx context.Context, cmd *cli.Command) error {
if err := os.Chdir(cmd.String("top")); err != nil {
if err := os.Chdir(cmd.String("top-dir")); err != nil {
return err
}

Expand All @@ -516,30 +516,30 @@ func DiffCheckActionFunc(ctx context.Context, cmd *cli.Command) error {
}

func EnsureGoimportsActionFunc(ctx context.Context, cmd *cli.Command) error {
top := cmd.String("top")
if err := os.Chdir(top); err != nil {
topDir := cmd.String("top-dir")
if err := os.Chdir(topDir); err != nil {
return err
}

if err := runCmd(
ctx,
"goimports",
"-d",
filepath.Join(top, "internal/build/build.go"),
filepath.Join(topDir, "internal/build/build.go"),
); err == nil {
return nil
}

os.Setenv("GOBIN", filepath.Join(top, ".local/bin"))
os.Setenv("GOBIN", filepath.Join(topDir, ".local/bin"))

return runCmd(ctx, "go", "install", "golang.org/x/tools/cmd/goimports@latest")
}

func EnsureGfmrunActionFunc(ctx context.Context, cmd *cli.Command) error {
top := cmd.String("top")
gfmrunExe := filepath.Join(top, ".local/bin/gfmrun")
topDir := cmd.String("top-dir")
gfmrunExe := filepath.Join(topDir, ".local/bin/gfmrun")

if err := os.Chdir(top); err != nil {
if err := os.Chdir(topDir); err != nil {
return err
}

Expand All @@ -561,7 +561,7 @@ func EnsureGfmrunActionFunc(ctx context.Context, cmd *cli.Command) error {
}

func EnsureMkdocsActionFunc(ctx context.Context, cmd *cli.Command) error {
if err := os.Chdir(cmd.String("top")); err != nil {
if err := os.Chdir(cmd.String("top-dir")); err != nil {
return err
}

Expand All @@ -584,7 +584,7 @@ func SetMkdocsRemoteActionFunc(ctx context.Context, cmd *cli.Command) error {
return errors.New("empty github token")
}

if err := os.Chdir(cmd.String("top")); err != nil {
if err := os.Chdir(cmd.String("top-dir")); err != nil {
return err
}

Expand All @@ -600,12 +600,12 @@ func SetMkdocsRemoteActionFunc(ctx context.Context, cmd *cli.Command) error {
}

func LintActionFunc(ctx context.Context, cmd *cli.Command) error {
top := cmd.String("top")
if err := os.Chdir(top); err != nil {
topDir := cmd.String("top-dir")
if err := os.Chdir(topDir); err != nil {
return err
}

out, err := sh(ctx, filepath.Join(top, ".local/bin/goimports"), "-l", ".")
out, err := sh(ctx, filepath.Join(topDir, ".local/bin/goimports"), "-l", ".")
if err != nil {
return err
}
Expand All @@ -621,7 +621,7 @@ func LintActionFunc(ctx context.Context, cmd *cli.Command) error {
}

func V3Diff(ctx context.Context, cmd *cli.Command) error {
if err := os.Chdir(cmd.String("top")); err != nil {
if err := os.Chdir(cmd.String("top-dir")); err != nil {
return err
}

Expand Down

0 comments on commit 817dcbc

Please sign in to comment.