Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check duplicated sub command name and alias #1805

Merged
merged 1 commit into from Aug 21, 2023

Conversation

linrl3
Copy link

@linrl3 linrl3 commented Aug 19, 2023

What type of PR is this?

  • bug

What this PR does / why we need it:

Fix #785.

Which issue(s) this PR fixes:

Fix #785

Special notes for your reviewer:

This fix is only for v2. Do we need to fix it in other versions?

Testing

  • I test it in unit test.
  • Also, I write a dummy program and see the output:
package main

import (
	"fmt"

	"github.com/urfave/cli/v2"
)

func main() {
	app := &cli.App{
		Name: "linrl3",
		Commands: []*cli.Command{
			{Name: "sub1"},
			{Name: "sub1"},
		},
	}
	if err := app.Run([]string{"linrl3", "sub1"}); err != nil {
		fmt.Println(err)
	}
}

result:

result:
➜  cli git:(fix/v2_duplicate_subcommand) ✗ go run cmd/dummyrun/main.go
parent command [linrl3] has duplicated subcommand name or alias: sub1

Release Notes

(REQUIRED)

- fix: if sub-commands in the same level have same name or alias, an error would return

@linrl3 linrl3 requested a review from a team as a code owner August 19, 2023 03:32
@linrl3 linrl3 force-pushed the fix/v2_duplicate_subcommand branch from 4c30734 to 5f20f10 Compare August 19, 2023 03:35
@linrl3 linrl3 changed the title fix: check duplicated command name in all commands fix: check duplicated sub command name and alias Aug 19, 2023
@linrl3 linrl3 force-pushed the fix/v2_duplicate_subcommand branch from 5f20f10 to 695594a Compare August 19, 2023 03:49
command.go Outdated Show resolved Hide resolved
command.go Outdated Show resolved Hide resolved
@linrl3 linrl3 force-pushed the fix/v2_duplicate_subcommand branch 2 times, most recently from 79da4fa to 8572933 Compare August 20, 2023 00:17
command.go Outdated Show resolved Hide resolved
@linrl3 linrl3 force-pushed the fix/v2_duplicate_subcommand branch from 8572933 to a4389c3 Compare August 20, 2023 13:18
command.go Outdated Show resolved Hide resolved
@linrl3 linrl3 force-pushed the fix/v2_duplicate_subcommand branch from a4389c3 to 8ab701e Compare August 21, 2023 05:13
@abitrolly
Copy link
Contributor

On the surface LGTM. Need somebody to get into deeper logic, like using new error module for v2 branch.

@linrl3 linrl3 force-pushed the fix/v2_duplicate_subcommand branch from 8ab701e to 57a3722 Compare August 21, 2023 12:10
@linrl3
Copy link
Author

linrl3 commented Aug 21, 2023

On the surface LGTM. Need somebody to get into deeper logic, like using new error module for v2 branch.

@abitrolly Who do you think should review the code? Could you invite him/her?

Copy link
Contributor

@dearchap dearchap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@linrl3 Thank you so much for your PR.

command.go Outdated Show resolved Hide resolved
@linrl3 linrl3 force-pushed the fix/v2_duplicate_subcommand branch 2 times, most recently from 64386cd to 77c9e15 Compare August 21, 2023 14:52
@linrl3
Copy link
Author

linrl3 commented Aug 21, 2023

@linrl3 Thank you so much for your PR.

@dearchap Thanks! What is the next step? Is there a routine merging and release?

@dearchap dearchap merged commit 488e77c into urfave:v2-maint Aug 21, 2023
10 checks passed
eddiebeazer pushed a commit to eddiebeazer/unreal-ci that referenced this pull request Dec 2, 2023
[![Mend Renovate logo
banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/urfave/cli/v2](https://togithub.com/urfave/cli) | require
| minor | `v2.25.7` -> `v2.26.0` |

---

### Release Notes

<details>
<summary>urfave/cli (github.com/urfave/cli/v2)</summary>

### [`v2.26.0`](https://togithub.com/urfave/cli/releases/tag/v2.26.0)

[Compare
Source](https://togithub.com/urfave/cli/compare/v2.25.7...v2.26.0)

#### What's Changed

- Bash completion nits by
[@&#8203;meatballhat](https://togithub.com/meatballhat) in
[urfave/cli#1762
- Chore: Rename mkdocs requirements file name by
[@&#8203;dearchap](https://togithub.com/dearchap) in
[urfave/cli#1776
- Fix:(issue\_1787) Add fix for commands not listed when hide help
comma… by [@&#8203;dearchap](https://togithub.com/dearchap) in
[urfave/cli#1788
- Fix nil HelpFlag panic (v2) by
[@&#8203;wxiaoguang](https://togithub.com/wxiaoguang) in
[urfave/cli#1795
- Always get 0 for a nested int64 value in v2.25.7 by
[@&#8203;stephenfire](https://togithub.com/stephenfire) in
[urfave/cli#1799
- Helper messages for documenting build process by
[@&#8203;abitrolly](https://togithub.com/abitrolly) in
[urfave/cli#1800
- fix: check duplicated sub command name and alias by
[@&#8203;linrl3](https://togithub.com/linrl3) in
[urfave/cli#1805
- Fix:(issue\_1689) Have consistent behavior for default text in man
and… by [@&#8203;dearchap](https://togithub.com/dearchap) in
[urfave/cli#1825
- Fix linting issues by
[@&#8203;skelouse](https://togithub.com/skelouse) in
[urfave/cli#1696

#### New Contributors

- [@&#8203;stephenfire](https://togithub.com/stephenfire) made their
first contribution in
[urfave/cli#1799
- [@&#8203;linrl3](https://togithub.com/linrl3) made their first
contribution in
[urfave/cli#1805

**Full Changelog**:
urfave/cli@v2.25.7...v2.26.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/eddiebeazer/unreal-ci).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy41OS44IiwidXBkYXRlZEluVmVyIjoiMzcuNTkuOCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
another-rex pushed a commit to google/osv-scanner that referenced this pull request Dec 3, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/go-git/go-git/v5](https://togithub.com/go-git/go-git) |
require | patch | `v5.10.0` -> `v5.10.1` |
| [github.com/urfave/cli/v2](https://togithub.com/urfave/cli) | require
| minor | `v2.25.7` -> `v2.26.0` |
| golang.org/x/exp | require | digest | `9a3e603` -> `6522937` |
| golang.org/x/term | require | minor | `v0.14.0` -> `v0.15.0` |

---

### Release Notes

<details>
<summary>go-git/go-git (github.com/go-git/go-git/v5)</summary>

### [`v5.10.1`](https://togithub.com/go-git/go-git/releases/tag/v5.10.1)

[Compare
Source](https://togithub.com/go-git/go-git/compare/v5.10.0...v5.10.1)

#### What's Changed

- Worktree, ignore ModeSocket files by
[@&#8203;steiler](https://togithub.com/steiler) in
[go-git/go-git#930
- git: add tracer package by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[go-git/go-git#916
- remote: Flip clause for fast-forward only check by
[@&#8203;adityasaky](https://togithub.com/adityasaky) in
[go-git/go-git#875
- plumbing: transport/ssh, Fix nil pointer dereference caused when an
unreachable proxy server is set. Fixes
[#&#8203;900](https://togithub.com/go-git/go-git/issues/900) by
[@&#8203;anandf](https://togithub.com/anandf) in
[go-git/go-git#901
- plumbing: uppload-server-info, implement upload-server-info by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[go-git/go-git#896
- plumbing: optimise memory consumption for filesystem storage by
[@&#8203;pjbgf](https://togithub.com/pjbgf) in
[go-git/go-git#799
- plumbing: format/packfile, Refactor patch delta by
[@&#8203;pjbgf](https://togithub.com/pjbgf) in
[go-git/go-git#908
- plumbing: fix empty uploadpack request error by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[go-git/go-git#932
- plumbing: transport/git, Improve tests error message by
[@&#8203;pjbgf](https://togithub.com/pjbgf) in
[go-git/go-git#752
- plumbing: format/pktline, Respect pktline error-line errors by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[go-git/go-git#936
- utils: remove ioutil.Pipe and use std library io.Pipe by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[go-git/go-git#922
- utils: move trace to utils by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[go-git/go-git#931
- cli: separate go module for cli by
[@&#8203;aymanbagabas](https://togithub.com/aymanbagabas) in
[go-git/go-git#914
- build: bump github.com/google/go-cmp from 0.5.9 to 0.6.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[go-git/go-git#887
- build: bump actions/setup-go from 3 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[go-git/go-git#891
- build: bump github.com/skeema/knownhosts from 1.2.0 to 1.2.1 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[go-git/go-git#888
- build: bump actions/checkout from 3 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[go-git/go-git#890
- build: bump golang.org/x/sys from 0.13.0 to 0.14.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[go-git/go-git#907
- build: bump golang.org/x/text from 0.13.0 to 0.14.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[go-git/go-git#906
- build: bump golang.org/x/crypto from 0.14.0 to 0.15.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[go-git/go-git#917
- build: bump golang.org/x/net from 0.17.0 to 0.18.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[go-git/go-git#918

#### New Contributors

- [@&#8203;anandf](https://togithub.com/anandf) made their first
contribution in
[go-git/go-git#901
- [@&#8203;steiler](https://togithub.com/steiler) made their first
contribution in
[go-git/go-git#930

**Full Changelog**:
go-git/go-git@v5.10.0...v5.10.1

</details>

<details>
<summary>urfave/cli (github.com/urfave/cli/v2)</summary>

### [`v2.26.0`](https://togithub.com/urfave/cli/releases/tag/v2.26.0)

[Compare
Source](https://togithub.com/urfave/cli/compare/v2.25.7...v2.26.0)

#### What's Changed

- Bash completion nits by
[@&#8203;meatballhat](https://togithub.com/meatballhat) in
[urfave/cli#1762
- Chore: Rename mkdocs requirements file name by
[@&#8203;dearchap](https://togithub.com/dearchap) in
[urfave/cli#1776
- Fix:(issue\_1787) Add fix for commands not listed when hide help
comma… by [@&#8203;dearchap](https://togithub.com/dearchap) in
[urfave/cli#1788
- Fix nil HelpFlag panic (v2) by
[@&#8203;wxiaoguang](https://togithub.com/wxiaoguang) in
[urfave/cli#1795
- Always get 0 for a nested int64 value in v2.25.7 by
[@&#8203;stephenfire](https://togithub.com/stephenfire) in
[urfave/cli#1799
- Helper messages for documenting build process by
[@&#8203;abitrolly](https://togithub.com/abitrolly) in
[urfave/cli#1800
- fix: check duplicated sub command name and alias by
[@&#8203;linrl3](https://togithub.com/linrl3) in
[urfave/cli#1805
- Fix:(issue\_1689) Have consistent behavior for default text in man
and… by [@&#8203;dearchap](https://togithub.com/dearchap) in
[urfave/cli#1825
- Fix linting issues by
[@&#8203;skelouse](https://togithub.com/skelouse) in
[urfave/cli#1696

#### New Contributors

- [@&#8203;stephenfire](https://togithub.com/stephenfire) made their
first contribution in
[urfave/cli#1799
- [@&#8203;linrl3](https://togithub.com/linrl3) made their first
contribution in
[urfave/cli#1805

**Full Changelog**:
urfave/cli@v2.25.7...v2.26.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 6am on monday" in timezone
Australia/Sydney, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/google/osv-scanner).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy44MS4zIiwidXBkYXRlZEluVmVyIjoiMzcuODEuMyIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->
renovate bot added a commit to woodpecker-ci/woodpecker that referenced this pull request Dec 4, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| code.gitea.io/sdk/gitea | require | minor | `v0.16.0` -> `v0.17.0` |
| [github.com/antonmedv/expr](https://togithub.com/antonmedv/expr) |
require | patch | `v1.15.5` -> `v1.15.6` |
| [github.com/golang-jwt/jwt/v5](https://togithub.com/golang-jwt/jwt) |
require | minor | `v5.1.0` -> `v5.2.0` |
| [github.com/urfave/cli/v2](https://togithub.com/urfave/cli) | require
| minor | `v2.25.7` -> `v2.26.0` |

---

### Release Notes

<details>
<summary>antonmedv/expr (github.com/antonmedv/expr)</summary>

###
[`v1.15.6`](https://togithub.com/expr-lang/expr/releases/tag/v1.15.6)

[Compare
Source](https://togithub.com/antonmedv/expr/compare/v1.15.5...v1.15.6)

-   This is a new release for `expr-lang/epxr`.

</details>

<details>
<summary>golang-jwt/jwt (github.com/golang-jwt/jwt/v5)</summary>

### [`v5.2.0`](https://togithub.com/golang-jwt/jwt/releases/tag/v5.2.0)

[Compare
Source](https://togithub.com/golang-jwt/jwt/compare/v5.1.0...v5.2.0)

#### What's Changed

- Exported `NewValidator` by
[@&#8203;oxisto](https://togithub.com/oxisto) in
[golang-jwt/jwt#349
- Improve ErrInvalidKeyType error messages by
[@&#8203;Laurin-Notemann](https://togithub.com/Laurin-Notemann) in
[golang-jwt/jwt#361
- Update MIGRATION_GUIDE.md by
[@&#8203;jbarham](https://togithub.com/jbarham) in
[golang-jwt/jwt#363

#### New Contributors

- [@&#8203;Laurin-Notemann](https://togithub.com/Laurin-Notemann) made
their first contribution in
[golang-jwt/jwt#361
- [@&#8203;jbarham](https://togithub.com/jbarham) made their first
contribution in
[golang-jwt/jwt#363

**Full Changelog**:
golang-jwt/jwt@v5.1.0...v5.2.0

</details>

<details>
<summary>urfave/cli (github.com/urfave/cli/v2)</summary>

### [`v2.26.0`](https://togithub.com/urfave/cli/releases/tag/v2.26.0)

[Compare
Source](https://togithub.com/urfave/cli/compare/v2.25.7...v2.26.0)

#### What's Changed

- Bash completion nits by
[@&#8203;meatballhat](https://togithub.com/meatballhat) in
[urfave/cli#1762
- Chore: Rename mkdocs requirements file name by
[@&#8203;dearchap](https://togithub.com/dearchap) in
[urfave/cli#1776
- Fix:(issue\_1787) Add fix for commands not listed when hide help
comma… by [@&#8203;dearchap](https://togithub.com/dearchap) in
[urfave/cli#1788
- Fix nil HelpFlag panic (v2) by
[@&#8203;wxiaoguang](https://togithub.com/wxiaoguang) in
[urfave/cli#1795
- Always get 0 for a nested int64 value in v2.25.7 by
[@&#8203;stephenfire](https://togithub.com/stephenfire) in
[urfave/cli#1799
- Helper messages for documenting build process by
[@&#8203;abitrolly](https://togithub.com/abitrolly) in
[urfave/cli#1800
- fix: check duplicated sub command name and alias by
[@&#8203;linrl3](https://togithub.com/linrl3) in
[urfave/cli#1805
- Fix:(issue\_1689) Have consistent behavior for default text in man
and… by [@&#8203;dearchap](https://togithub.com/dearchap) in
[urfave/cli#1825
- Fix linting issues by
[@&#8203;skelouse](https://togithub.com/skelouse) in
[urfave/cli#1696

#### New Contributors

- [@&#8203;stephenfire](https://togithub.com/stephenfire) made their
first contribution in
[urfave/cli#1799
- [@&#8203;linrl3](https://togithub.com/linrl3) made their first
contribution in
[urfave/cli#1805

**Full Changelog**:
urfave/cli@v2.25.7...v2.26.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am" (UTC), Automerge -
"before 4am" (UTC).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/woodpecker-ci/woodpecker).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy44MS4zIiwidXBkYXRlZEluVmVyIjoiMzcuODEuMyIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: qwerty287 <ndev@web.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants