Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

single require to use like optparse

#102

This is the suggestion John made; have a single file to require that effectively will allow a file to define and launch a task, so that the task basically serves as an option parser.

Reported by bahuvrihi · September 10th, 2008 @ 10:14 AM

State: resolved
Milestone: Tap-0.11.0
Assigned to: bahuvrihi bahuvrihi

Activity

  1. bahuvrihi
    bahuvrihi
    • State changed from new to resolved
    • Assigned user set to bahuvrihi

    Ok, so it works like this:

    
    #!/usr/bin/env ruby
    
    require 'rubygems'
    require 'tap'
    
    # Goodnight::manifest your basic goodnight moon task
    # Says goodnight with a configurable message.
    Tap.tasc('goodnight', :message => 'goodnight') do |name|
      log message, name
      "#{message} #{name}"
    end.execute
    

    September 12th, 2008 @ 11:50 AM

  2. bahuvrihi
    bahuvrihi

    Maybe even better (so that the class definition can be used in other context without executing):

    
    
    #!/usr/bin/env ruby
    
    require 'rubygems'
    require 'tap'
    
    # Goodnight::manifest your basic goodnight moon task
    # Says goodnight with a configurable message.
    Tap.tasc('goodnight', :message => 'goodnight') do |name|
      log message, name
      "#{message} #{name}"
    end
    
    Goodnight.execute if __FILE__ == $0
    
    

    September 13th, 2008 @ 12:38 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.