From 0ab59c0d0009e4c393f0efcd09fcb324e568c2b2 Mon Sep 17 00:00:00 2001 From: Simon Stelling Date: Sat, 14 Dec 2019 20:33:51 +0100 Subject: [PATCH] Fix shell completion for commands with dashes in their name (#104) --- CHANGELOG.md | 2 ++ .../com/github/ajalt/clikt/completion/CompletionGenerator.kt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ff8dab22..446f7761d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +### Fixed +- Shell completion can now handle command names with dashes. ([#104](/~https://github.com/ajalt/clikt/issues/104)) ## [2.3.0] - 2019-11-07 ### Added diff --git a/clikt/src/main/kotlin/com/github/ajalt/clikt/completion/CompletionGenerator.kt b/clikt/src/main/kotlin/com/github/ajalt/clikt/completion/CompletionGenerator.kt index fe996a5cb..2d16792ef 100644 --- a/clikt/src/main/kotlin/com/github/ajalt/clikt/completion/CompletionGenerator.kt +++ b/clikt/src/main/kotlin/com/github/ajalt/clikt/completion/CompletionGenerator.kt @@ -119,7 +119,7 @@ internal object CompletionGenerator { for (name in subcommands) { append(""" | $name) - | ${funcName}_$name ${'$'}(( i + 1 )) + | ${funcName}_${name.replace('-', '_')} ${'$'}(( i + 1 )) | return | ;; |