-
Notifications
You must be signed in to change notification settings - Fork 262
feat(help): Improve help command output. #425
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -55,13 +55,13 @@ pub enum CustomTaskSubcommand { | |||||||||||
| #[clap(allow_hyphen_values = true, trailing_var_arg = true)] | ||||||||||||
| args: Vec<String>, | ||||||||||||
| }, | ||||||||||||
| /// Build application | ||||||||||||
| /// Build for production | ||||||||||||
| #[command(disable_help_flag = true)] | ||||||||||||
| Build { | ||||||||||||
| #[clap(allow_hyphen_values = true, trailing_var_arg = true)] | ||||||||||||
| args: Vec<String>, | ||||||||||||
| }, | ||||||||||||
| /// Run test | ||||||||||||
| /// Run tests | ||||||||||||
| #[command(disable_help_flag = true)] | ||||||||||||
| Test { | ||||||||||||
| #[clap(allow_hyphen_values = true, trailing_var_arg = true)] | ||||||||||||
|
|
@@ -92,7 +92,6 @@ pub enum CustomTaskSubcommand { | |||||||||||
| args: Vec<String>, | ||||||||||||
| }, | ||||||||||||
| /// Install command. | ||||||||||||
| /// It will be passed to the package manager's install command currently. | ||||||||||||
| #[command(disable_help_flag = true, alias = "i")] | ||||||||||||
| Install { | ||||||||||||
| #[clap(allow_hyphen_values = true, trailing_var_arg = true)] | ||||||||||||
|
|
@@ -611,6 +610,11 @@ pub async fn main( | |||||||||||
| // Get args from parameter or env::args() | ||||||||||||
| // When running from NAPI, args should be passed explicitly to skip node/script paths | ||||||||||||
| let args_vec: Vec<String> = args.unwrap_or_else(|| env::args().skip(1).collect()); | ||||||||||||
| let args_vec = normalize_help_args(args_vec); | ||||||||||||
| if should_print_help(&args_vec) { | ||||||||||||
| print_help(); | ||||||||||||
| return Ok(ExitStatus::SUCCESS); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Parse CLI args using vite_task::CLIArgs | ||||||||||||
| // Prepend "vite" as program name for clap | ||||||||||||
|
|
@@ -703,6 +707,47 @@ pub async fn main( | |||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| fn normalize_help_args(args: Vec<String>) -> Vec<String> { | ||||||||||||
| args | ||||||||||||
|
||||||||||||
| args | |
| args | |
| .into_iter() | |
| .map(|arg| if arg == "help" { "--help".to_string() } else { arg }) | |
| .collect() |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||
| use std::process::ExitStatus; | ||||||
|
|
||||||
| use clap::{Parser, Subcommand}; | ||||||
| use clap::{CommandFactory, Parser, Subcommand}; | ||||||
| use vite_error::Error; | ||||||
| use vite_install::commands::{ | ||||||
| add::SaveDependencyType, install::InstallCommandOptions, outdated::Format, | ||||||
|
|
@@ -15,16 +15,7 @@ use crate::commands::{ | |||||
|
|
||||||
| #[derive(Parser, Debug)] | ||||||
| #[clap(author, version, about, long_about = None)] | ||||||
| #[command( | ||||||
| disable_help_subcommand = true, | ||||||
| help_template = "\ | ||||||
| vite+/{version} | ||||||
|
|
||||||
| {usage-heading} {usage} | ||||||
|
|
||||||
| {all-args}{after-help} | ||||||
| " | ||||||
| )] | ||||||
| #[command(disable_help_subcommand = true)] | ||||||
| pub struct Args { | ||||||
| #[clap(subcommand)] | ||||||
| pub commands: Commands, | ||||||
|
|
@@ -406,6 +397,24 @@ pub enum Commands { | |||||
| #[arg(last = true, allow_hyphen_values = true)] | ||||||
| pass_through_args: Option<Vec<String>>, | ||||||
| }, | ||||||
| /// View package information from registry | ||||||
| #[command(alias = "view", alias = "show")] | ||||||
| Info { | ||||||
| /// Package name with optional version | ||||||
| #[arg(required = true)] | ||||||
| package: String, | ||||||
|
|
||||||
| /// Specific field to view | ||||||
| field: Option<String>, | ||||||
|
|
||||||
| /// Output in JSON format | ||||||
| #[arg(long)] | ||||||
| json: bool, | ||||||
|
|
||||||
| /// Additional arguments to pass through to the package manager | ||||||
| #[arg(last = true, allow_hyphen_values = true)] | ||||||
| pass_through_args: Option<Vec<String>>, | ||||||
| }, | ||||||
| /// Link packages for local development | ||||||
| #[command(alias = "ln")] | ||||||
| Link { | ||||||
|
|
@@ -433,7 +442,7 @@ pub enum Commands { | |||||
| #[arg(allow_hyphen_values = true, trailing_var_arg = true)] | ||||||
| args: Vec<String>, | ||||||
| }, | ||||||
| /// Package manager utilities | ||||||
| /// Forward command to the package manager. | ||||||
|
||||||
| /// Forward command to the package manager. | |
| /// Forward command to the package manager |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new Info command forwards to PmCommands::View but there's no test coverage demonstrating that the top-level vite info command works correctly. Consider adding a test case to verify that vite info <package> properly delegates to the package manager's view/info command, similar to how other package manager commands are tested in the snap-tests directory.
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The help text displays "new" as a command, but the actual command is defined as "Gen" in the Commands enum (line 467). While the JavaScript code intercepts both "new" and "gen" commands before reaching Rust, it would be more consistent to add an alias attribute to the Gen command definition to make it clear in the code that both names are supported. This would improve code clarity and make it easier for future maintainers to understand that "new" is an officially supported alias.
| {bold}new{reset} Generate a new project | |
| {bold}gen{reset} (alias: new) Generate a new project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description comment for the Install command was removed. While this change makes the documentation more concise, the removed comment provided useful context that the install command currently forwards to the package manager. Consider keeping a brief note about this forwarding behavior, as it helps developers understand the command's implementation.