File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -625,7 +625,7 @@ def normalize_command_name(meth) #:nodoc:
625625 # alias name.
626626 def find_command_possibilities ( meth )
627627 len = meth . to_s . length
628- possibilities = all_commands . merge ( map ) . keys . select { |n | meth == n [ 0 , len ] } . sort
628+ possibilities = all_commands . reject { | k , v | v . is_a? ( HiddenCommand ) } . merge ( map ) . keys . select { |n | meth == n [ 0 , len ] } . sort
629629 unique_possibilities = possibilities . map { |k | map [ k ] || k } . uniq
630630
631631 if possibilities . include? ( meth )
Original file line number Diff line number Diff line change @@ -129,6 +129,16 @@ Linebreaks preserved
129129 true
130130 end
131131
132+ desc "potentially_ambiguous" , "not really ambiguous because conflicting command is hidden"
133+ def potentially_ambiguous
134+ true
135+ end
136+
137+ desc "potentially_ambiguous_but_hidden" , "not considered for ambiguous check because it's hidden" , hide : true
138+ def potentially_ambiguous_but_hidden
139+ false
140+ end
141+
132142 private
133143
134144 def method_missing ( meth , *args )
Original file line number Diff line number Diff line change @@ -522,6 +522,10 @@ def self.exit_on_failure?
522522 it "invokes an alias" do
523523 expect ( MyScript . start ( %w( animal_pri ) ) ) . to eq ( MyScript . start ( %w( zoo ) ) )
524524 end
525+
526+ it "invokes a command, even when there's a hidden command that makes invokation ambiguous" do
527+ expect ( MyScript . start ( %w( potentially_ ) ) ) . to eq ( MyScript . start ( %w( potentially_ambiguous ) ) )
528+ end
525529 end
526530
527531 context "when the user enters an ambiguous substring of a command" do
You can’t perform that action at this time.
0 commit comments