File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,16 @@ def type
3232 nil
3333 end
3434 end
35+
36+ def candidates
37+ @children . map { |c , n |
38+ ss = n . candidates
39+ ss . empty? ? c :
40+ ss . map { |s |
41+ c +s
42+ }
43+ } . flatten
44+ end
3545 end
3646
3747 # config: { type: [commands...], ... }
@@ -60,6 +70,7 @@ def search str, if_none = nil
6070 return if_none
6171 end
6272 end
73+ yield trie . candidates . map { |s | str + s } if block_given?
6374 if_none
6475 end
6576 end
Original file line number Diff line number Diff line change @@ -786,7 +786,10 @@ def register_default_command
786786 end
787787
788788 if sub
789- sub = info_subcommands_abbrev . search sub , :unknown
789+ sub = info_subcommands_abbrev . search sub , :unknown do |candidates |
790+ # note: unreached now
791+ @ui . puts "Ambiguous command '#{ sub } ': #{ candidates . join ( ' ' ) } "
792+ end
790793 end
791794
792795 case sub
You can’t perform that action at this time.
0 commit comments