I'm looking for a way to create a command-line thor app that will run a default method without any arguments. I fiddled with Thor's default_method option, but still requires that I pass in an argument. I found a similar case where someone wanted to run a CLI Thor task with arguments but without a task name.
I'd like to run a task with no task name and no arguments. Is such a thing possible?
It seems the proper Thor-way to do this is using
default_task
:If for whatever reason that isn't what you need, you should be able to do something like
While it is a little hackish, I solved a similar problem by catching the option as the argument itself:
When running in a
Thor::Group
this method is executed before others and lets me trick the program into responding to an option like argument.This code is from https://github.com/neverstopbuilding/blam.
Kind of hackish, but where there's only one defined action anyway, I just prepended the action name to the
ARGV
array that gets passed in:Then where I start the class by passing in ARGV: