Sha256: c4d7fe239192551ada67f40bb3585f53b24104769ad545dc58928b15740af6dc

Contents?: true

Size: 1.13 KB

Versions: 15

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env ruby
$: << File.dirname(__FILE__)+'/../lib'
require 'configliere'

puts "This is a demo of Configliere in a simple script."
Settings.use :commandline, :config_file, :define

puts "You can set default values:"
Settings({
  :dest_time => '1955-11-05',
  :delorean => {
    :power_source => 'plutonium',
    :roads_needed => true,
    },
})
puts "  #{Settings.inspect}"

config_filename = File.dirname(__FILE__)+'/simple_script.yaml'
puts "\nYou can load values from a file -- in this case, #{config_filename} -- which overrides the defaults:"
Settings.read config_filename
Settings.resolve!
puts "  #{Settings.inspect}"

puts %Q{\nTry running the script with commandline parameters, for example
  #{$0} --dest_time=2015-11-05 --delorean.roads_needed="" --delorean.power_source="Mr. Fusion"
In this case, you used
  #{$0} #{ARGV.map{|argv| "'#{argv}'"}.join(" ")}
and so the final parameter values are}
Settings.resolve!
puts "  #{Settings.inspect}"

saved_filename = '/tmp/simple_script_saved.yaml'
puts %Q{\nYou can save the defaults out to a config file.  These settings have been written to #{saved_filename}}
Settings.save!(saved_filename)

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
configliere-0.3.4 examples/simple_script.rb
configliere-0.3.3 examples/simple_script.rb
configliere-0.2.3 examples/simple_script.rb
configliere-0.3.2 examples/simple_script.rb
configliere-0.3.1 examples/simple_script.rb
configliere-0.3.0 examples/simple_script.rb
configliere-0.2.2 examples/simple_script.rb
configliere-0.2.1 examples/simple_script.rb
configliere-0.1.1 examples/simple_script.rb
configliere-0.1.0 examples/simple_script.rb
configliere-0.0.9 examples/simple_script.rb
configliere-0.0.8 examples/simple_script.rb
configliere-0.0.7 examples/simple_script.rb
configliere-0.0.6 examples/simple_script.rb
configliere-0.0.5 examples/simple_script.rb