# Verify that the various forms of requesting the top-level help.

exec cue
cmp stdout stdout.golden

exec cue help
cmp stdout stdout.golden

exec cue --help
cmp stdout stdout.golden

exec cue -h
cmp stdout stdout.golden

# Requesting help for commands and sub-commands.

exec cue help mod
stdout -count=1 'groups commands which operate on CUE modules'
stdout -count=1 'publish *publish the current module to a registry$'

exec cue mod --help
stdout -count=1 'groups commands which operate on CUE modules'
stdout -count=1 'publish *publish the current module to a registry$'

exec cue help mod publish
stdout -count=1 '^Publish the current module to an OCI registry\.'

exec cue mod publish --help
stdout -count=1 '^Publish the current module to an OCI registry\.'

# Requesting additional help topics; the form without "help" is phased out.

exec cue help filetypes
stdout -count=1 '^The cue tool supports the following file types:$'

! exec cue filetypes
! stdout .
stderr -count=1 '^unknown command'

# Requesting help for missing commands and sub-commands fails and prints the help text.

! exec cue help missing
! stdout .
stderr -count=1 'Unknown help topic: missing'
stderr -count=1 '^Available Commands:$'

! exec cue help mod missing
! stdout .
stderr -count=1 'Unknown help topic: mod missing'
stderr -count=1 '^Available Commands:$'

# Requesting the help text for the help command itself is a bit silly.
# `cue help` already describes how to query help for commands or topics.
# Fail even though technically "help" is a valid command, just a special one.
! exec cue help help
stderr -count=1 'Unknown help topic: help'

-- stdout.golden --
CUE makes it easy to validate data, write schemas,
and ensure configurations align with policies.

CUE works with a wide range of tools and formats that you're already using
such as Go, JSON, YAML, OpenAPI, and JSON Schema.

For more information and documentation, see: https://cuelang.org

Available Commands:
  cmd         run a user-defined workflow command
  completion  Generate completion script
  def         print consolidated definitions
  eval        evaluate and print a configuration
  export      output data in a standard format
  fix         rewrite packages to latest standards
  fmt         formats CUE configuration files
  get         add non-CUE dependencies to the current module
  import      convert other formats to CUE files
  login       log into a CUE registry
  mod         module maintenance
  trim        remove superfluous fields
  version     print the CUE version and build information
  vet         validate data

Use "cue help [command]" for more information about a command.

Additional help topics:
  cue help commands       user-defined commands
  cue help embed          file embedding
  cue help environment    environment variables
  cue help experiments    experimental language features
  cue help filetypes      supported file types and qualifiers
  cue help flags          common flags for composing packages
  cue help injection      inject files or values into specific fields for a build
  cue help inputs         package list, patterns, and files
  cue help modules        module support
  cue help registryconfig module registry configuration
