diff --git a/crates/vite_global_cli/src/cli.rs b/crates/vite_global_cli/src/cli.rs index 509bab7a40..257db99f34 100644 --- a/crates/vite_global_cli/src/cli.rs +++ b/crates/vite_global_cli/src/cli.rs @@ -298,9 +298,13 @@ pub enum EnvSubcommands { Print, /// Set or show the global default Node.js version + #[command(after_long_help = "\ +Examples: + vp env default # Show the current default + vp env default lts # Set the default")] Default { - /// Version to set as default (e.g., "20.18.0", "lts", "latest") - /// If not provided, shows the current default + /// Version to set as default (e.g., "20.18.0", "lts", "latest"). + /// If omitted, prints the current default. version: Option, }, @@ -330,9 +334,14 @@ pub enum EnvSubcommands { }, /// Pin a Node.js version in the current directory (creates .node-version) + #[command(after_long_help = "\ +Examples: + vp env pin lts # Pin to latest LTS + vp env pin --unpin # Remove .node-version + vp env pin \"^20.0.0\" --force # Overwrite existing pin")] Pin { - /// Version to pin (e.g., "20.18.0", "lts", "latest", "^20.0.0") - /// If not provided, shows the current pinned version + /// Version to pin (e.g., "20.18.0", "lts", "latest", "^20.0.0"). + /// If omitted, prints the currently pinned version. version: Option, /// Remove the .node-version file from current directory @@ -383,11 +392,17 @@ pub enum EnvSubcommands { }, /// Execute a command with a specific Node.js version - #[command(visible_alias = "run")] + #[command( + visible_alias = "run", + after_long_help = "\ +Examples: + vp env exec --node lts npm install # Pin version for this invocation + vp env exec node -v # Shim mode: version auto-resolved" + )] Exec { - /// Node.js version to use (e.g., "20.18.0", "lts", "^20.0.0") - /// If not provided and command is node/npm/npx or a global package binary, - /// version is resolved automatically (same as shim behavior) + /// Node.js version to use (e.g., "20.18.0", "lts", "^20.0.0"). + /// If omitted and command is node/npm/npx or a global package binary, + /// version is resolved automatically (same as shim behavior). #[arg(long)] node: Option, @@ -417,9 +432,13 @@ pub enum EnvSubcommands { }, /// Use a specific Node.js version for this shell session + #[command(after_long_help = "\ +Examples: + vp env use lts # Override session with latest LTS + vp env use --unset # Clear the session override")] Use { - /// Version to use (e.g., "20", "20.18.0", "lts", "latest") - /// If not provided, reads from .node-version or package.json + /// Version to use (e.g., "20", "20.18.0", "lts", "latest"). + /// If omitted, reads from .node-version or package.json. version: Option, /// Remove session override (revert to file-based resolution) diff --git a/packages/cli/snap-tests-global/command-env-use/snap.txt b/packages/cli/snap-tests-global/command-env-use/snap.txt index fccb629ff4..020a267bc2 100644 --- a/packages/cli/snap-tests-global/command-env-use/snap.txt +++ b/packages/cli/snap-tests-global/command-env-use/snap.txt @@ -4,7 +4,7 @@ Usage: vp env use [OPTIONS] [VERSION] Use a specific Node.js version for this shell session Arguments: - [VERSION] Version to use (e.g., "20", "20.18.0", "lts", "latest") If not provided, reads from .node-version or package.json + [VERSION] Version to use (e.g., "20", "20.18.0", "lts", "latest"). If omitted, reads from .node-version or package.json Options: --unset Remove session override (revert to file-based resolution) @@ -12,6 +12,10 @@ Options: --silent-if-unchanged Suppress output if version is already active -h, --help Print help +Examples: + vp env use lts # Override session with latest LTS + vp env use --unset # Clear the session override + Documentation: https://viteplus.dev/guide/env