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

cmd/cue: help $blah does not error for non-existent $blah #2918

Closed
myitcv opened this issue Mar 6, 2024 · 1 comment
Closed

cmd/cue: help $blah does not error for non-existent $blah #2918

myitcv opened this issue Mar 6, 2024 · 1 comment
Labels
modules Issues related to CUE modules and the experimental implementation NeedsFix

Comments

@myitcv
Copy link
Member

myitcv commented Mar 6, 2024

What version of CUE are you using (cue version)?

$ cue version
cue version v0.0.0-20240304165426-7d4d90de3798

go version go1.22.0
      -buildmode exe
       -compiler gc
  DefaultGODEBUG httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
     CGO_ENABLED 1
          GOARCH arm64
            GOOS linux
             vcs git
    vcs.revision 7d4d90de3798a00807f50373466322771bd0a10a
        vcs.time 2024-03-04T16:54:26Z
    vcs.modified false

Does this issue reproduce with the latest release?

Yes

What did you do?

! exec cue help mod rubbish
stderr 'unknown command "mod rubbish"'

What did you expect to see?

Passing test (for some variation of the stderr expectation)

What did you see instead?

$ ts repro.txtar
> ! exec cue help mod rubbish
[stdout]


Usage:
  cue mod <cmd> [arguments] [flags]
  cue mod [command]

Available Commands:
  get         add and upgrade module dependencies
  init        initialize new module in current directory
  publish     publish the current module to a registry
  tidy        download and tidy module dependencies

Global Flags:
  -E, --all-errors   print all available errors
  -i, --ignore       proceed in the presence of errors
  -s, --simplify     simplify output
      --strict       report errors for lossy mappings
      --trace        trace computation
  -v, --verbose      print information about progress

Use "cue mod [command] --help" for more information about a command.
FAIL: /tmp/testscript1456235653/repro.txtar/script.txtar:1: unexpected command success

i.e. cue help mod rubbish exists with a 0 exit code for an unknown command mod rubbish

@myitcv myitcv added NeedsFix modules Issues related to CUE modules and the experimental implementation labels Mar 6, 2024
@mvdan
Copy link
Member

mvdan commented Mar 6, 2024

Similar to #2560, but likely not the same fix as cue cmd needs to load a CUE package to figure out what commands are available.

cueckoo pushed a commit that referenced this issue May 3, 2024
We cover all edge cases now; a missing help command, sub-command,
and "cmd" command, as well as all the valid help combinations.

Note that for unknown "cmd" commands we print a more precise error,
and we also check that custom commands are added to the help text
in all cases where we print help text for cmd.

We join help_hello.txtar with help_cmd.txtar given their overlap.

Thanks to Naoki Kuroda for proposing a version of the fix in #2759
which was adapted here, along with more testscript coverage.

Fixes #2560.
Fixes #2918.
Closes #2759 as partially merged.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I252e57c59eab499e40daea45355f1da75acba249
@cueckoo cueckoo closed this as completed in 1be0b0f May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules Issues related to CUE modules and the experimental implementation NeedsFix
Projects
Archived in project
Development

No branches or pull requests

2 participants