Using a different name for calling a ruby gem from the command line
command-line-interface, ruby
Solution
Your gem name and the executables it bundles don't have to be the same at all. In your gemspec, you can define a list of executables via `executables`:
Gem::Specification.new do |s|
s.name = "super_awesome_gem"
# other gemspec stuff
s.executables = ["sup_awe"]
end
As long as `sup_awe` is listed in the gemspec's `files` list, and is executable, that will be in the user's path after they install your gem. Bundler, when bootstrapping your gemspec, makes this even simpler
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
Anything in `bin/` will be treated as an executable.
That is the long way of saying that your exectuable/bin file can be named whatever you want, and doesn't have to be named for your gem.
Problem
Is there any way to change the name that the user has to use when calling from the command line? For example, I have a Thor command line app called super_awesome_gem. I want my gem to be called super_awesome_gem, but when the user calls it from the command line I just want them to be able to call sup_awe or something. I've tried editing the gemspec file and the file and folder names, but I can't figure out what the proper way to do this would be, or even if there is one. Is there a way to name a gem one way and have the command line call be a different name?