Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/discover/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,30 @@ mod tests {
);
}

#[test]
fn test_rewrite_dotnet_subcommands() {
// All four subcommands have dedicated `rtk dotnet` proxies, so the rewrite
// rule must route them (issue #1830 — only `build` was covered before).
for sub in ["build", "test", "restore", "format"] {
assert_eq!(
rewrite_command_no_prefixes(&format!("dotnet {}", sub), &[]),
Some(format!("rtk dotnet {}", sub)),
"dotnet {} should rewrite",
sub
);
}
// Trailing args are preserved (the \b stops at the subcommand).
assert_eq!(
rewrite_command_no_prefixes("dotnet test --filter Category=Unit", &[]),
Some("rtk dotnet test --filter Category=Unit".into())
);
// Subcommands without a proxy must NOT be rewritten.
assert_eq!(rewrite_command_no_prefixes("dotnet publish", &[]), None);
assert_eq!(rewrite_command_no_prefixes("dotnet run", &[]), None);
// Word boundary guards against false prefixes.
assert_eq!(rewrite_command_no_prefixes("dotnet builder", &[]), None);
}

#[test]
fn test_rewrite_compound_and() {
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion src/discover/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ pub const RULES: &[RtkRule] = &[
subcmd_status: &[],
},
RtkRule {
pattern: r"^dotnet\s+build\b",
pattern: r"^dotnet\s+(build|test|restore|format)\b",
rtk_cmd: "rtk dotnet",
rewrite_prefixes: &["dotnet"],
category: "Build",
Expand Down