Skip to content

Delegate command's --help to local cli #1995

Description

@liangmiQwQ

Describe the bug

When using global cli, vp <dev/pack/bulid etc.> --help does not delegate to local cli. Instead, Vite+ maintained a help.rs to record all commands

This can cause bugs: when the global Vite+'s cli version is different from local cli's, the help document will mismatch with the real behavior.

What's more, I don't think having a document in global cli is good for maintaining, it requires Vite+ to update help.rs when upstream gets update every single time. It has already had some mismatch.

$ vp dev --help
VITE+ - The Unified Toolchain for the Web

Usage: vp dev [ROOT] [OPTIONS]

Run the development server.
Options are forwarded to Vite.

Arguments:
  [ROOT]  Project root directory (default: current directory)

Options:
  --host [HOST]        Specify hostname
  --port <PORT>        Specify port
  --open [PATH]        Open browser on startup
  --strictPort         Exit if specified port is already in use
  -c, --config <FILE>  Use specified config file
  --base <PATH>        Public base path
  -m, --mode <MODE>    Set env mode
  -h, --help           Print help
  # ⚠️⚠️ Missed: `--force`, `--experimentalBundle`, `--debug` etc. ⚠️⚠️

Examples:
  vp dev
  vp dev --open
  vp dev --host localhost --port 5173

Documentation: https://viteplus.dev/guide/dev

However, directly delegating help document to local may bring new challenge. Different tools have different output formats. Vite itself, Vitest and tsdown use cac (no color / special format), while Oxlint and Oxfmt use its own colorful output, Vite+'s commands like vp check use viteplus style output. It's hard to make all tools' output unified. But I still believe document correctness should take precedence over brand consistency.

Reproduction

https://github.com/liang-demos/vite-plus-help-message-mismatch.git

Steps to reproduce

vp dev --help
vpr localhelp --help

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Fields

Priority

None yet

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions