Thor gem: how to display a USAGE: banner when passing in 0 arguments

So I can’t find any good place to post this question, unless I’m filing
it
as a bug to the gem authors. Before I do that, I’m hoping someone in
this
group might know the answer.

With the Thor http://rubygems.org/gems/thor gem, it looks to do
almost everything I need to create a pretty rich command-line interface
for
generating scaffolding for a project. I want to provide the user a
“usage
banner” when they call the app without passing any arguments. I don’t
know/can’t find the documentation stating how this is configured in an
app.
Does anyone have a simple code example that shows how this might be
done?

class App < Thor

desc “do awesome stuff”
def awesomeifier

end

def no_args
# print some banner or something
end

end

App.start

-Nick K.

Okay, so it’s not really explained in the README, but it’s in the docs.
I’m
not looking for a BANNER, i’m looking for
default_taskhttp://rdoc.info/github/wycats/thor/master/Thor.default_task,
which I can output something useful with it:
http://rdoc.info/github/wycats/thor/master/Thor.default_task

So, say you have a class:

class App < Thor

desc “foo”, “do foo things”
def foo

end


end

You want a default task? Well, you might also want to display the help
while you’re at it:

class App < Thor

default_task :the_banner

desc “help”, “my help, not Thor’s”
def the_banner
puts <<-THING

You can put anything here, why not? This is a help doc, afterall.
THING
help # call help to tack on those useful Task descriptions
end
end

and when you run the thing from the command-line:

$ ruby app.rb

You can put anything here, why not? This is a help doc, afterall.
Tasks:
app.rb help # my help, not Thor’s
app.rb help [TASK] # Describe available tasks or one specific task

http://rdoc.info/github/wycats/thor/master/Thor.default_task
-Nick K.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs