10000 Merge remote-tracking branch 'origin/main' into applying-pr1218 · urfave/cli@e66ce91 · GitHub
[go: up one dir, main page]

Skip to content

Commit e66ce91

Browse files
committed
Merge remote-tracking branch 'origin/main' into applying-pr1218
2 parents 6c811a8 + 5c1c2ea commit e66ce91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+868
-290
lines changed

.github/workflows/cli.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: vet
3838
run: go run internal/build/build.go vet
3939

40-
- name: test with tags
40+
- name: test with urfave_cli_no_docs tag
4141
run: go run internal/build/build.go -tags urfave_cli_no_docs test
4242

4343
- name: test
@@ -47,7 +47,7 @@ jobs:
4747
run: go run internal/build/build.go check-binary-size
4848

4949
- name: check-binary-size with tags (informational only)
50-
run: go run internal/build/build.go -tags urfave_cli_no_docs check-binary-size || true
50+
run: go run internal/build/build.go -tags urfave_cli_no_docs check-binary-size
5151

5252
- name: Upload coverage to Codecov
5353
if: success() && matrix.go == '1.18.x' && matrix.os == 'ubuntu-latest'
@@ -76,19 +76,37 @@ jobs:
7676
uses: actions/checkout@v3
7777

7878
- name: Install Dependencies
79-
run:
80-
mkdir -p "${GITHUB_WORKSPACE}/.local/bin" &&
81-
curl -fsSL -o "${GITHUB_WORKSPACE}/.local/bin/gfmrun" "https://github.com/urfave/gfmrun/releases/download/v1.3.0/gfmrun-$(go env GOOS)-$(go env GOARCH)-v1.3.0" &&
82-
chmod +x "${GITHUB_WORKSPACE}/.local/bin/gfmrun" &&
83-
npm install -g markdown-toc@1.2.0
79+
run: |
80+
mkdir -p "${GITHUB_WORKSPACE}/.local/bin"
81+
curl -fsSL -o "${GITHUB_WORKSPACE}/.local/bin/gfmrun" "https://github.com/urfave/gfmrun/releases/download/v1.3.0/gfmrun-$(go env GOOS)-$(go env GOARCH)-v1.3.0"
82+
chmod +x "${GITHUB_WORKSPACE}/.local/bin/gfmrun"
8483
8584
- name: gfmrun
8685
run: go run internal/build/build.go gfmrun docs/v2/manual.md
8786

88-
- name: toc
89-
run: go run internal/build/build.go toc docs/v2/manual.md
90-
9187
- name: diff check
9288
run: |
9389
git diff --exit-code
9490
git diff --cached --exit-code
91+
92+
publish:
93+
if: startswith(github.ref, 'refs/tags/')
94+
name: publish
95+
needs: [test-docs]
96+
runs-on: ubuntu-latest
97+
steps:
98+
- name: Checkout Code
99+
uses: actions/checkout@v3
100+
with:
101+
fetch-depth: 0
102+
103+
- name: Setup mkdocs
104+
run: |
105+
pip install -U pip
106+
pip install -r mkdocs-requirements.txt
107+
git remote rm origin
108+
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/urfave/cli.git
109+
110+
- name: Publish Docs
111+
run: |
112+
mkdocs gh-deploy --force

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
*.coverprofile
22
*.orig
3-
node_modules/
43
vendor
54
.idea
65
internal/*/built-example
76
coverage.txt
87
/.local/
8+
/site/
99

1010
*.exe

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# attention on files that are primarily Go.
66

77
.PHONY: all
8-
all: generate vet tag-test test check-binary-size tag-check-binary-size gfmrun toc v2diff
8+
all: generate vet tag-test test check-binary-size tag-check-binary-size gfmrun v2diff
99

1010
# NOTE: this is a special catch-all rule to run any of the commands
1111
# defined in internal/build/build.go with optional arguments passed
@@ -27,6 +27,14 @@ tag-check-binary-size:
2727
gfmrun:
2828
go run internal/build/build.go gfmrun docs/v2/manual.md
2929

30-
.PHONY: toc
31-
toc:
32-
go run internal/build/build.go toc docs/v2/manual.md
30+
.PHONY: docs
31+
docs:
32+
mkdocs build
33+
34+
.PHONY: docs-deps
35+
docs-deps:
36+
pip install -r mkdocs-requirements.txt
37+
38+
.PHONY: serve-docs
39+
serve-docs:
40+
mkdocs serve

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ You can use the following build tags:
6363

6464
When set, this removes `ToMarkdown` and `ToMan` methods, so your application
6565
won't be able to call those. This reduces the resulting binary size by about
66-
300-400 KB (measured using Go 1.18.1 on Linux/amd64), due to less dependencies.
66+
300-400 KB (measured using Go 1.18.1 on Linux/amd64), due to fewer dependencies.
6767

6868
### GOPATH
6969

app.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ type App struct {
9494
// single-character bool arguments into one
9595
// i.e. foobar -o -v -> foobar -ov
9696
UseShortOptionHandling bool
97+
// Enable suggestions for commands and flags
98+
Suggest bool
9799

98100
didSetup bool
99101
}
@@ -264,6 +266,11 @@ func (a *App) RunContext(ctx context.Context, arguments []string) (err error) {
264266
return err
265267
}
266268
_, _ = fmt.Fprintf(a.Writer, "%s %s\n\n", "Incorrect Usage.", err.Error())
269+
if a.Suggest {
270+
if suggestion, err := a.suggestFlagFromError(err, ""); err == nil {
271+
fmt.Fprintf(a.Writer, suggestion)
272+
}
273+
}
267274
_ = ShowAppHelp(cCtx)
268275
return err
269276
}
@@ -383,6 +390,11 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) {
383390
return err
384391
}
385392
_, _ = fmt.Fprintf(a.Writer, "%s %s\n\n", "Incorrect Usage.", err.Error())
393+
if a.Suggest {
394+
if suggestion, err := a.suggestFlagFromError(err, cCtx.Command.Name); err == nil {
395+
fmt.Fprintf(a.Writer, suggestion)
396+
}
397+
}
386398
_ = ShowSubcommandHelp(cCtx)
387399
return err
388400
}

command.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ func (c *Command) Run(ctx *Context) (err error) {
119119
}
120120
_, _ = fmt.Fprintln(cCtx.App.Writer, "Incorrect Usage:", err.Error())
121121
_, _ = fmt.Fprintln(cCtx.App.Writer)
122+
if ctx.App.Suggest {
123+
if suggestion, err := ctx.App.suggestFlagFromError(err, c.Name); err == nil {
124+
fmt.Fprintf(cCtx.App.Writer, suggestion)
125+
}
126+
}
122127
_ = ShowCommandHelp(cCtx, c.Name)
123128
return err
124129
}
@@ -249,6 +254,7 @@ func (c *Command) startApp(ctx *Context) error {
249254
app.ErrWriter = ctx.App.ErrWriter
250255
app.ExitErrHandler = ctx.App.ExitErrHandler
251256
app.UseShortOptionHandling = ctx.App.UseShortOptionHandling
257+
app.Suggest = ctx.App.Suggest
252258

253259
app.categories = newCommandCategories()
254260
for _, command := range c.Subcommands {

docs/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cli.urfave.org

docs/CODE_OF_CONDUCT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../CODE_OF_CONDUCT.md

docs/CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,28 @@ line help system which may be consulted for further information, e.g.:
9898
go run internal/genflags/cmd/genflags/main.go --help
9999
```
100100

101+
#### docs output
102+
103+
The documentation in the `docs` directory is automatically built via `mkdocs` into a
104+
static site and published when releases are pushed (see [RELEASING](./RELEASING/)). There
105+
is no strict requirement to build the documentation when developing locally, but the
106+
following `make` targets may be used if desired:
107+
108+
```sh
109+
# install documentation dependencies with `pip`
110+
make docs-deps
111+
```
112+
113+
```sh
114+
# build the static site in `./site`
115+
make docs
116+
```
117+
118+
```sh
119+
# start an mkdocs development server
120+
make serve-docs
121+
```
122+
101123
### pull requests
102124

103125
Please feel free to open a pull request to fix a bug or add a feature. The @urfave/cli

docs/index.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Welcome to urfave/cli
2+
3+
[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://pkg.go.dev/github.com/urfave/cli/v2)
4+
[![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-urfave-cli)
5+
[![Go Report Card](https://goreportcard.com/badge/urfave/cli)](https://goreportcard.com/report/urfave/cli)
6+
[![codecov](https://codecov.io/gh/urfave/cli/branch/main/graph/badge.svg)](https://codecov.io/gh/urfave/cli)
7+
8+
`urfave/cli` is a simple, fast, and fun package for building command line apps in Go. The
9+
goal is to enable developers to write fast and distributable command line applications in
10+
an expressive way.
11+
12+
These are the guides for each major supported version:
13+
14+
- [`v2`](./v2/)
15+
- [`v1`](./v1/)
16+
17+
In addition to the version-specific guides, these other documents are available:
18+
19+
- [CONTRIBUTING](./CONTRIBUTING/)
20+
- [CODE OF CONDUCT](./CODE_OF_CONDUCT/)
21+
- [RELEASING](./RELEASING/)

0 commit comments

Comments
 (0)
0