Skip to content

Shell completion works wrongly even if double dash -- are included in arguments #1932

@suzuki-shunsuke

Description

@suzuki-shunsuke

My urfave/cli version is

v2.27.2

Checklist

  • Are you running the latest v2 release? The list of releases is here.
  • Did you check the manual for your release? The v2 manual is here
  • Did you perform a search about this problem? Here's the GitHub guide about searching.

Dependency Management

  • My project is using go modules.

Describe the bug

I created a GitHub repository to reproduce the issue.
Please read README.md.

https://github.com/suzuki-shunsuke/reproduce-urfave-cli-shell-completion-issue

To reproduce

Describe the steps or code required to reproduce the behavior

https://github.com/suzuki-shunsuke/reproduce-urfave-cli-shell-completion-issue

Observed behavior

What did you see happen immediately after the reproduction steps
above?

https://github.com/suzuki-shunsuke/reproduce-urfave-cli-shell-completion-issue

Expected behavior

What would you have expected to happen immediately after the
reproduction steps above?

https://github.com/suzuki-shunsuke/reproduce-urfave-cli-shell-completion-issue

Additional context

Add any other context about the problem here.

If the issue relates to a specific open source GitHub repo, please
link that repo here.

If you can reproduce this issue with a public CI system, please
link a failing build here.

This issue is related to my OSS project aqua, which is a CLI version manager written in Go.
aqua is using urfave/cli/v2 and is enabling shell completion.
aqua is a CLI version manager, and when a tool managed by aqua is executed, aqua intercepted the execution and executes the tool via aqua exec -- <command> [<argument> ...].
For example, if a tool lintnet is managed by aqua and lintnet --help is executed, actually aqua exec -- lintnet --help is executed.

For detail, please see the document. https://aquaproj.github.io/docs/reference/lazy-install/#how-does-lazy-install-work

This issue causes a problem that shell completion doesn't work well if a tool managed by aqua is also built with urfave/cli/v2.

Want to fix this yourself?

We'd love to have more contributors on this project! If the fix for
this bug is easily explained and very small, feel free to create a
pull request for it.

Yes.

Run go version and paste its output here

# paste `go version` output in here
go version go1.22.4 darwin/arm64

Run go env and paste its output here

# paste `go env` output in here
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/shunsukesuzuki/Library/Caches/go-build'
GOENV='/Users/shunsukesuzuki/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/shunsukesuzuki/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/shunsukesuzuki/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/shunsukesuzuki/.local/share/aquaproj-aqua/pkgs/http/golang.org/dl/go1.22.4.darwin-arm64.tar.gz/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/shunsukesuzuki/.local/share/aquaproj-aqua/pkgs/http/golang.org/dl/go1.22.4.darwin-arm64.tar.gz/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.4'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/shunsukesuzuki/repos/src/github.com/suzuki-shunsuke/reproduce-urfave-cli-shell-completion-issue/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/fc/1bgyy3_d3x90m_t04qbw5f8m0000gn/T/go-build2726066441=/tmp/go-build -gno-record-gcc-switches -fno-common'

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v2relates to / is being considered for v2kind/bugdescribes or fixes a bugstatus/triagemaintainers still need to look into this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions