-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default help task for subcommand shows the wrong command name #261
Comments
I'm seeing this too. Is there a way to override the subcommand name or is this a fixable issue with Thor's naming scheme? I named a class SSH. The underscores denote camel casing, which normally okay. When using acronyms it breaks here though. As a temporary workaround I used Ssh, ugly as it is, for a the name. |
You can do something like this:
This is probably not the most elegant solution. It would be nice if Thor.register would take the subcommand name in the description and not the class name. |
Any updates on this issue? |
Defining
And this is what happens now with my CLI
All available in this Gist |
Thanks @mattheworiordan, this is my take on it that overrides namespace (I was getting duplication with your changes and not fixing the over-the-top underscore-ing): require 'thor'
require 'active_support/inflector'
module MyMod
class Base < ::Thor
# Override banner method to correct missing subcommand.
# @see https://github.com/erikhuda/thor/issues/261
def self.banner(command, namespace = nil, subcommand = false)
return super if subcommand
"#{basename} #{self.namespace} #{command.formatted_usage(self, $thor_runner, subcommand)}"
end
# Override namespace inflection so acronyms don't get over underscored.
# Previously CLI -> c_l_i
# @see https://github.com/erikhuda/thor/issues/261
def self.namespace
ActiveSupport::Inflector.underscore(
ActiveSupport::Inflector.demodulize(name)
)
end
end
end |
@mattheworiordan solution doesn't work for me with sub-subcommands (I don't know if you were expecting it to). For example in my CLI Cut down and cleaned up output:
The second set of commands is missing the |
I have an executable, ziprecruiter, and it has a subcommand (group?) jobalerts. When I execute ziprecruiter, it displays jobalerts correctly (no underscore):
However, when I run jobalerts, it shows "c_l_i" instead of the correct "jobalerts":
But c_l_i doesn't exist:
I believe this has to do with the way I have my subcommand namespaced: ZipRecruiter::JobAlerts::CLI
The text was updated successfully, but these errors were encountered: