Skip to content

Commit 3bec9ce

Browse files
authored
refactor: auto-aliasing subcmds (#356)
1 parent 59ae229 commit 3bec9ce

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/command/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,11 @@ impl Command {
498498

499499
// auto alias if command name contains `_`
500500
if let Some(name) = self.name.clone() {
501-
let compatible_name = name
502-
.chars()
503-
.enumerate()
504-
.map(|(i, c)| if i > 0 && c == '_' { '-' } else { c })
505-
.collect::<String>();
501+
let compatible_name = if !name.starts_with('_') {
502+
name.replace("_", "-")
503+
} else {
504+
name.clone()
505+
};
506506
if compatible_name != name {
507507
match self.aliases.as_mut() {
508508
Some((aliaes, _)) => aliaes.insert(0, compatible_name),

0 commit comments

Comments
 (0)