I had some luck with this approach:
class CLI < Thor
map %w[--version -v] => :__print_version
desc "--version, -v", "print the version"
def __print_version
puts FooBar::VERSION
end
end
The leading underscores ensures there isn't a command like yourapp version
, and forces yourapp --version
or yourapp -v
. The desc
content will allow it to show up as -v, --version
without exposing __print_version
.