Sha256: c4e3d71dbf6caf01f04d0c142f838198dca71188ff92281c2cc382f448899703

Contents?: true

Size: 945 Bytes

Versions: 5

Compression:

Stored size: 945 Bytes

Contents

#!/usr/bin/env ruby
#
#  Created by Brian Marick on 2007-08-09.
#  Copyright (c) 2007. All rights reserved.

# See the tutorial for explanations.

### The following adjusts the load path so that the correct version of
### a self-contained package is found, no matter where the script is
### run from. 
require 'pathname'
$:.unshift((Pathname.new(__FILE__).parent.parent.parent + 'lib').to_s)
require 's4t-utils/load-path-auto-adjuster'

require 'pp'
require 'user-choices'

class TutorialExample < UserChoices::Command
  include UserChoices

  def add_sources(builder)
    builder.add_source(CommandLineSource, :usage,
                       "Usage: ruby #{$0} infile")
  end

  def add_choices(builder)
    builder.add_choice(:infile) { | command_line | 
      command_line.uses_arg
    }
  end
  
  def execute
    pp @user_choices
  end
end


if $0 == __FILE__
  S4tUtils.with_pleasant_exceptions do
    TutorialExample.new.execute
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
user-choices-1.1.0 examples/tutorial/tutorial5.rb
user-choices-1.1.1 examples/tutorial/tutorial5.rb
user-choices-1.1.4 examples/tutorial/tutorial5.rb
user-choices-1.1.2 examples/tutorial/tutorial5.rb
user-choices-1.1.3 examples/tutorial/tutorial5.rb