File: medium_example.rb

package info (click to toggle)
ruby-optimist 3.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 348 kB
  • sloc: ruby: 2,912; makefile: 4
file content (15 lines) | stat: -rwxr-xr-x 678 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env ruby
require_relative '../lib/optimist'

opts = Optimist::options do
  version "cool-script v0.1 (code-name: bananas foster)"
  banner "This script is pretty cool."
  opt :juice, "use juice"
  opt :milk, "use milk"
  opt :litres, "quantity of liquid", :default => 2.0
  opt :brand, "brand name of the liquid", :type => :string
  opt :config, "config file path", :type => String, :required => true
  opt :drinkers, "number of people drinking the liquid", :default => 6
end
Optimist::die :drinkers, "must be value a greater than zero" if opts[:drinkers] < 1
Optimist::die :config, "must point to an existing file" unless File.exist?(opts[:config]) if opts[:config]