From: Nick Klauer Date: 2011-04-13T10:30:40+09:00 Subject: Re: Thor gem: how to display a USAGE: banner when passing in 0 arguments --00032555a16e11a27804a0c2c1f9 Content-Type: text/plain; charset=UTF-8 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_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 -Nick Klauer On Fri, Apr 8, 2011 at 10:50, Nick Klauer wrote: > 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 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 Klauer > --00032555a16e11a27804a0c2c1f9--