Skip to content

Commit 8eebf3d

Browse files
zaniebMtkN1
authored andcommitted
Remove commands available in the top-level from the suggested subcommand error (astral-sh#8316)
Part of astral-sh#8313 I think we'll need to open an issue upstream to add more context to the error here, because there's not sufficient information about the parent command to provide a good error message. As a first step, let's avoid giving these suggestions for subcommands that overlap with our top-level commands.. because that's just confusing. Here's all the information we have here ```rust [crates/uv/src/lib.rs:1530:13] &err = ErrorInner { kind: InvalidSubcommand, context: FlatMap { keys: [ InvalidSubcommand, Usage, ], values: [ String( "remove", ), StyledStr( StyledStr( "\u{1b}[1m\u{1b}[32mUsage:\u{1b}[0m \u{1b}[1m\u{1b}[36muv python\u{1b}[0m \u{1b}[36m[OPTIONS]\u{1b}[0m \u{1b}[36m<COMMAND>\u{1b}[0m", ), ), ], }, message: None, source: None, help_flag: Some( "--help", ), styles: Styles { header: Style { fg: Some( Ansi( Green, ), ), bg: None, underline: None, effects: Effects(BOLD), }, error: Style { fg: Some( Ansi( Red, ), ), bg: None, underline: None, effects: Effects(BOLD), }, usage: Style { fg: Some( Ansi( Green, ), ), bg: None, underline: None, effects: Effects(BOLD), }, literal: Style { fg: Some( Ansi( Cyan, ), ), bg: None, underline: None, effects: Effects(BOLD), }, placeholder: Style { fg: Some( Ansi( Cyan, ), ), bg: None, underline: None, effects: Effects(), }, valid: Style { fg: Some( Ansi( Green, ), ), bg: None, underline: None, effects: Effects(), }, invalid: Style { fg: Some( Ansi( Yellow, ), ), bg: None, underline: None, effects: Effects(), }, }, color_when: Auto, color_help_when: Auto, backtrace: None, } ```
1 parent a3c348d commit 8eebf3d

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

crates/uv/src/lib.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,25 +1530,19 @@ where
15301530
if let Some(ContextValue::String(subcommand)) = err.get(ContextKind::InvalidSubcommand)
15311531
{
15321532
match subcommand.as_str() {
1533-
"compile" | "lock" => {
1533+
"compile" => {
15341534
err.insert(
15351535
ContextKind::SuggestedSubcommand,
15361536
ContextValue::String("uv pip compile".to_string()),
15371537
);
15381538
}
1539-
"sync" => {
1540-
err.insert(
1541-
ContextKind::SuggestedSubcommand,
1542-
ContextValue::String("uv pip sync".to_string()),
1543-
);
1544-
}
1545-
"install" | "add" => {
1539+
"install" => {
15461540
err.insert(
15471541
ContextKind::SuggestedSubcommand,
15481542
ContextValue::String("uv pip install".to_string()),
15491543
);
15501544
}
1551-
"uninstall" | "remove" => {
1545+
"uninstall" => {
15521546
err.insert(
15531547
ContextKind::SuggestedSubcommand,
15541548
ContextValue::String("uv pip uninstall".to_string()),
@@ -1572,12 +1566,6 @@ where
15721566
ContextValue::String("uv pip show".to_string()),
15731567
);
15741568
}
1575-
"tree" => {
1576-
err.insert(
1577-
ContextKind::SuggestedSubcommand,
1578-
ContextValue::String("uv pip tree".to_string()),
1579-
);
1580-
}
15811569
_ => {}
15821570
}
15831571
}

0 commit comments

Comments
 (0)