Make -h output usage info directly in CLI instead of launching TUI #1100

Closed
opened 2026-02-16 17:29:27 -05:00 by yindo · 9 comments
Owner

Originally created by @PeterDaveHello on GitHub (Aug 4, 2025).

Originally assigned to: @thdxr on GitHub.

--help already outputs the usage info correctly. The issue is that running opencode -h currently launches the TUI instead of printing help and usage information directly in the terminal, which is inconsistent with common CLI conventions.

Suggested improvements:

  • opencode -h should print usage and help text directly to the terminal, similar to how --version and --help work.
  • The output should include a summary of available flags, commands, and a brief description of the tool.

Updating this behavior would make OpenCode easier to use and more in line with what people expect from CLI tools. If this proposal is acceptable, I am happy to contribute a patch for this enhancement.

Originally created by @PeterDaveHello on GitHub (Aug 4, 2025). Originally assigned to: @thdxr on GitHub. `--help` already outputs the usage info correctly. The issue is that running `opencode -h` currently launches the TUI instead of printing help and usage information directly in the terminal, which is inconsistent with common CLI conventions. Suggested improvements: - `opencode -h` should print usage and help text directly to the terminal, similar to how `--version` and `--help` work. - The output should include a summary of available flags, commands, and a brief description of the tool. Updating this behavior would make OpenCode easier to use and more in line with what people expect from CLI tools. If this proposal is acceptable, I am happy to contribute a patch for this enhancement.
yindo closed this issue 2026-02-16 17:29:27 -05:00
Author
Owner

@rekram1-node commented on GitHub (Aug 4, 2025):

@PeterDaveHello
Does opencode --help really not print help text? I know -h won't since it is used for hostname but if --help won't either that's very unexpected:

For me opencode --help works:

 opencode --help

█▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀
█░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀
▀▀▀▀ █▀▀▀ ▀▀▀ ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀  ▀▀▀

Commands:
  opencode [project]         start opencode tui                        [default]
  opencode run [message..]   run opencode with a message
  opencode auth              manage credentials
  opencode agent             manage agents
  opencode upgrade [target]  upgrade opencode to the latest or a specific
                             version
  opencode serve             starts a headless opencode server
  opencode models            list all available models
  opencode github            manage GitHub agent

Positionals:
  project  path to start opencode in                                    [string]

Options:
      --help        show help                                          [boolean]
  -v, --version     show version number                                [boolean]
      --print-logs  print logs to stderr                               [boolean]
      --log-level   log level
                            [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"]
  -m, --model       model to use in the format of provider/model        [string]
  -p, --prompt      prompt to use                                       [string]
      --mode        mode to use                                         [string]
      --port        port to listen on                      [number] [default: 0]
  -h, --hostname    hostname to listen on        [string] [default: "127.0.0.1"]
@rekram1-node commented on GitHub (Aug 4, 2025): @PeterDaveHello Does `opencode --help` really not print help text? I know -h won't since it is used for hostname but if --help won't either that's very unexpected: For me `opencode --help` works: ```zsh opencode --help █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀ █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀ ▀▀▀▀ █▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ Commands: opencode [project] start opencode tui [default] opencode run [message..] run opencode with a message opencode auth manage credentials opencode agent manage agents opencode upgrade [target] upgrade opencode to the latest or a specific version opencode serve starts a headless opencode server opencode models list all available models opencode github manage GitHub agent Positionals: project path to start opencode in [string] Options: --help show help [boolean] -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] -m, --model model to use in the format of provider/model [string] -p, --prompt prompt to use [string] --mode mode to use [string] --port port to listen on [number] [default: 0] -h, --hostname hostname to listen on [string] [default: "127.0.0.1"] ```
Author
Owner

@PeterDaveHello commented on GitHub (Aug 4, 2025):

@rekram1-node You're absolutely right, I must have been confused! I just tested it, and --help does work correctly and outputs the help text directly to the terminal as expected. It's specifically the -h flag that's missing this behavior since it's used for hostname. Thanks for the clarification and for pointing this out!

@PeterDaveHello commented on GitHub (Aug 4, 2025): @rekram1-node You're absolutely right, I must have been confused! I just tested it, and `--help` does work correctly and outputs the help text directly to the terminal as expected. It's specifically the `-h` flag that's missing this behavior since it's used for hostname. Thanks for the clarification and for pointing this out!
Author
Owner

@rekram1-node commented on GitHub (Aug 4, 2025):

Happy to help

@rekram1-node commented on GitHub (Aug 4, 2025): Happy to help
Author
Owner

@PeterDaveHello commented on GitHub (Aug 4, 2025):

Thanks again for your help!

I’ve updated the issue to clarify that only the -h flag is affected and that --help works correctly.

If adding -h support is acceptable, I’m happy to contribute a patch for this enhancement.

Looking forward to any feedback or suggestions!

@PeterDaveHello commented on GitHub (Aug 4, 2025): Thanks again for your help! I’ve updated the issue to clarify that only the `-h` flag is affected and that `--help` works correctly. If adding `-h` support is acceptable, I’m happy to contribute a patch for this enhancement. Looking forward to any feedback or suggestions!
Author
Owner

@PeterDaveHello commented on GitHub (Aug 4, 2025):

I sent a PR here: #1599, please feel free to take a look, thanks 😄

@PeterDaveHello commented on GitHub (Aug 4, 2025): I sent a PR here: #1599, please feel free to take a look, thanks 😄
Author
Owner

@thdxr commented on GitHub (Aug 4, 2025):

the thing with -h is we use that as an alias for host in other commands

@thdxr commented on GitHub (Aug 4, 2025): the thing with `-h` is we use that as an alias for `host` in other commands
Author
Owner

@PeterDaveHello commented on GitHub (Aug 6, 2025):

I saw the reminder in #1599. Just wanted to check if it might still be possible to implement the -h flag following common CLI conventions, since it's a frequently used parameter. If it's not feasible, that's totally understandable.

@PeterDaveHello commented on GitHub (Aug 6, 2025): I saw the reminder in #1599. Just wanted to check if it might still be possible to implement the `-h` flag following common CLI conventions, since it's a frequently used parameter. If it's not feasible, that's totally understandable.
Author
Owner

@PeterDaveHello commented on GitHub (Aug 21, 2025):

Another aspect worth considering: opencode -h launches the TUI without providing any hostname value, yet the help shows -h, --hostname hostname to listen on. If -h expects a hostname value, it should require one.

opencode auth -h returns exit code 1 with help text when used without required parameters. Since there's typically no use case for -h without a hostname (default behavior doesn't require the flag), having -h return non-zero when used without a hostname could provide clearer feedback and prevent silent execution that doesn't match the expected usage pattern.

@PeterDaveHello commented on GitHub (Aug 21, 2025): Another aspect worth considering: `opencode -h` launches the TUI without providing any hostname value, yet the help shows `-h, --hostname hostname to listen on`. If `-h` expects a hostname value, it should require one. `opencode auth -h` returns exit code 1 with help text when used without required parameters. Since there's typically no use case for `-h` without a hostname (default behavior doesn't require the flag), having `-h` return non-zero when used without a hostname could provide clearer feedback and prevent silent execution that doesn't match the expected usage pattern.
Author
Owner

@rekram1-node commented on GitHub (Aug 21, 2025):

good point @PeterDaveHello thing is yargs -h has a default value so even if you do -h we get default value, can't really error there easily

@rekram1-node commented on GitHub (Aug 21, 2025): good point @PeterDaveHello thing is yargs -h has a default value so even if you do -h we get default value, can't really error there easily
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1100