Skip to content
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

Commands that contain hyphens cannot be executed #868

Closed
naomichi-y opened this issue Jan 14, 2024 · 3 comments · Fixed by #878
Closed

Commands that contain hyphens cannot be executed #868

naomichi-y opened this issue Jan 14, 2024 · 3 comments · Fixed by #878

Comments

@naomichi-y
Copy link

In 1.3.0, it seems that the command cannot be executed if the command name includes hyphen.

class Test < Thor
  desc "foo-bar", "an example task"
  def foo_bar
    puts "I'm a thor task!"
  end
end
$ bundle exec thor test:foo-bar
Commands:
  thor test:foo-bar         # an example task
  thor test:help [COMMAND]  # Describe available commands or one specific command

Up to 1.2.2, the command was executed as intended.

$ bundle exec thor test:foo-bar
I'm a thor task!

Is this a feature change?
Looking at the change history, I can't find any related issues.

@naomichi-y naomichi-y changed the title `Commands that contain hyphens cannot be executed Commands that contain hyphens cannot be executed Jan 14, 2024
@naomichi-y
Copy link
Author

This is probably caused by Thor::Base.subclasses.detect not finding foo-bar.
By converting to command.tr('-', '_'), the behavior is the same as up to 1.2.2.

https://github.com/rails/thor/pull/754/files#diff-5393308169879c36b527bdc9a24a37e0e3939ad5e4a7b359d327645a7f5a714cR136

@rafaelfranca
Copy link
Member

Not intended. Can you please open a PR?

@takmar
Copy link
Contributor

takmar commented Mar 22, 2024

@rafaelfranca @naomichi-y
Hi. I fixed the issue so I created PR.

In addition to this problem, it seems that the alias method also did not work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants