Aliases should be visible via help #162

Closed
sferik opened this Issue Aug 23, 2011 · 10 comments

Projects

None yet

4 participants

@sferik
Member
sferik commented Aug 23, 2011

Let's say I specify an alias like so:

class CLI < Thor
  desc "hello", 'Says "hello"'
  def hello
    puts "hello"
  end
  map :h => :hello
end

If I then type:

./bin/command help hello

the output makes no mention of the alias. How is the user of the command supposed to know the alias exists?

This issue could be closed if issue #160 in resolved first.

@indirect
Contributor

I have a patch for Thor from Akira Matsuda that I am testing in Bundler that simply allows any unambiguous shortcut to work. That seems nicer than explicit mapping all around, yeah?

@indirect
Contributor

Although I should point out that it will not allow command help h to work. That said, I don't really think that that ought to work?

@sferik
Member
sferik commented Aug 23, 2011

I agree that we should allow any unambiguous command to work (ambiguous commands should throw a warning, informing the user of the ambiguity as in rubygems...for example, try typing gem l). I said as much in the last line of my issue.

I don't understand why the disambiguator couldn't work for help as well? In my example above, if a user is accustomed to typing command h, they would probably expect command help h to work.

@indirect
Contributor

I think it's just a side-effect of the implementation, which changes the invoke code, not the help code. Here's the patch: bundler/bundler@8b1af1...b541209

@sferik
Member
sferik commented Aug 23, 2011

I'd resist merging that patch until it handles the help case.

@eventualbuddha
Contributor

I had a negative first reaction to handling the help case, but I think it makes sense... it's at least consistent.

@sferik sferik added a commit that closed this issue Aug 28, 2011
@sferik sferik Automatically create aliases for unambiguous substrings of commands
Inspired by the code in RubyGems, this code goes beyond that basic case
to correctly resolve ambiguous aliases that map to the same command.

Closes #158.
Closes #160.
Closes #162.
a0e3e20
@sferik sferik closed this in a0e3e20 Aug 28, 2011
@sferik
Member
sferik commented Aug 29, 2011

@indirect with this patch, Akira Matsuda's code can be removed from bundler as soon as bundler is updated to use thor 0.15.

@indirect
Contributor

Nice! 👍

On Aug 29, 2011, at 11:12 AM, sferik wrote:

@indirect with this patch, Akira Matsuda's code can be removed from bundler as soon as bundler is updated to user thor 0.15.

Reply to this email directly or view it on GitHub:
#162 (comment)

@amatsuda
Contributor
amatsuda commented Sep 2, 2011

Nice work @sferik!
But, have you actually confirmed this?

with this patch, Akira Matsuda's code can be removed from bundler as soon as bundler is updated to usr thor 0.15.

I tried to apply your change set on current Bundler master, but it didn't work for me :(

@sferik
Member
sferik commented Sep 2, 2011

@amatsuda It works for me!

I had to run the following rake task in bundler to re-vendor thor:

rake vendor:build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment