-
Notifications
You must be signed in to change notification settings - Fork 553
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
Thor::Group registered as subcommand can't find arguments. #149
Comments
I filed a pull request here: #150 |
I don't think that patch fixes this problem, but then It's 4:00 am and I just finished figuring this out so I'm going to post a workaround instead. class Foo < Thor::Group
argument :name
def first_method
p name
end
end
Thor::Runner.register Foo, "foo", "USAGE", "DESC"
#Hackery here!
Thor::Runner.tasks["foo"].options = Foo.class_options Basically you're getting the class options from the I can't for the life of me determine what the correct behavior is supposed to be in this case, but this is the most DRY way I could find to propogate the options for subcommands. |
I am using my patch for a quite a while now and it's working without a doubt. |
I created a sample thor app called Thorax https://github.com/anithri/thorax. Using just this one patch, I can't get the correct behavior. So, there could be other things in the master branch that does fix this. I'll fork and apply and try it out. For the meantime, here's my results for simply applying your patch to Thor 0.14.6
The
|
My patch fixes the "passing through" of arguments but doesn't touch the options, but I haven't experienced any problems with the options on my side. |
I think I found the discrepancy while playing with the Thor Specs. Thor uses #lib/thorax/stuff.rb Line: ~10
Thorax::Runner.register Thorax::Stuff, :stuff, "stuff", "print more stuff" #then you see...
% bundle exec bin/thorax
Tasks:
thorax bar # print bar
thorax foo # print foo
thorax help [TASK] # Describe available tasks or one specific task
thorax stuff # print more stuff
Options:
[--config=CONFIG] # configuration file.
# Default: ~/.thoraxrc
% bundle exec bin/thorax stuff
Tasks:
thorax baz # print baz
thorax help [COMMAND] # Describe subcommands or one specific subcommand
% bundle exec bin/thorax stuff baz
default default default While what I am doing is using I think that my use of register as useful as the existing one. So the question is how best to codify it.
I'd be happy to write specs and code to implement this, given a nudge in the right direction. |
I want to register a Thor::Group as a subcommand to another Thor class which fails when introducing arguments to the Thor::Group.
I am using the same technique to add regular Thor tasks as subcommands which works fine.
running the command without argument fails (as expected) because of a missing argument:
but running the command with an argument fails as well:
Can anyone provide workarounds or solutions to this problem,
I was going through the source but couldn't point it out.
The text was updated successfully, but these errors were encountered: