bin/rconf in rconf-0.9.25 vs bin/rconf in rconf-0.10.0
- old
+ new
@@ -20,11 +20,11 @@
include ProgressReporter
def self.run
opts = Trollop::options do
- version "rconf #{VERSION} (c) 2011 RightScale"
+ version "rconf #{VERSION} (c) 2012 RightScale"
banner <<-EOS
#{DESCRIPTION}
Usage:
rconf [options]
@@ -32,15 +32,16 @@
where [options] are:
EOS
opt :configurators, 'Show available configurators'
opt :platform, 'Show current platform'
+ opt :overrides, 'Show current overrides'
opt :update, 'Update rconf to latest version'
opt :remove, 'Remove rconf from all gemsets'
opt :config, 'Set path to configuration file', :type => :string
opt :output, 'Output file (output to STDOUT by default)', :type => :string
- opt :reconfigure, 'Bypass all checks and force configuration'
+ opt :reconfigure, 'Bypass all checks and force configuration and ignore overrides'
opt :force, 'Run rconf even if configuration file has not changed'
opt :verbose,'Print debug output'
end
if opts[:config].nil? && !opts[:configurators] && !opts[:update] && !opts[:remove]
opts[:config] = Dir["./*#{CONFIG_EXTENSION}"]
@@ -60,10 +61,12 @@
Command.set_verbose if opts[:verbose]
if opts[:configurators]
new.list_configurators
elsif opts[:platform]
new.show_platform
+ elsif opts[:overrides]
+ new.show_overrides
elsif opts[:update]
new.update
elsif opts[:remove]
new.remove
else
@@ -79,20 +82,18 @@
puts "The following configurators are registered:\n\n"
ConfiguratorRegistry.each do |key, configurator|
puts "== #{key} ==".bold
puts configurator.desc
puts 'Settings:'
- max_size = configurator.all_settings.keys.map(&:to_s).map(&:size).max
- configurator.all_settings.each do |name, desc|
- num_spaces = max_size - name.to_s.size + 1
- print " - #{name.to_s.blue}:#{' ' * num_spaces}#{desc}"
- required_settings = configurator.required_settings || []
- if required_settings.include?(name)
- puts ' [required]'.green
- else
- puts
- end
+ max_size = configurator.all_settings.map { |s| s[:name] }.map(&:size).max
+ configurator.all_settings.each do |setting|
+ name = setting[:name]
+ desc = setting[:description]
+ options = setting[:options].keys.map { |k| "[#{k}]" }.join(' ')
+ num_spaces = max_size - name.size + 1
+ print " - #{name.blue}:#{' ' * num_spaces}#{desc}"
+ puts ' ' + options.green
end
puts
end
end
@@ -105,20 +106,46 @@
puts "Family: #{Platform.family}"
puts "Flavor: #{Platform.flavor}"
puts "Release: #{Platform.release}"
end
+ # List current overrides as defined in ~/.rconf_overrides
+ #
+ # === Return
+ # true:: Always return true
+ def show_overrides
+ if !File.readable?(OverridesLanguage::OVERRIDES_FILE)
+ puts "No rconf overrides file at #{OverridesLanguage::OVERRIDES_FILE}"
+ else
+ overrides = OverridesLanguage.load
+ if overrides
+ puts "Loading overrides from #{OverridesLanguage::OVERRIDES_FILE}"
+ msg = ''
+ overrides.each do |key, setting|
+ msg += "* #{key}\n" +
+ msg += setting.inject([]) do |m, (name, value)|
+ m << " - #{name} = #{value}"
+ m
+ end.join("\n")
+ end
+ puts msg
+ else
+ puts "Failed to load overrides from #{OverridesLanguage::OVERRIDES_FILE}: #{OverridesLanguage.parse_error.error_message}"
+ end
+ end
+ end
+
# Update rconf to latest in all installed rubies
#
# === Return
# true:: Always return true
def update
ProgressReporter.report_to_stdout
report_check 'Retrieving latest rconf...'
json = Command.execute('curl', '-s', 'http://rubygems.org/api/v1/gems/rconf.json').output
json =~ /"version":"([^"]+)"/
- version = Regexp.last_match(1)
+ version = Regexp.last_match(1)
report_fatal 'Failed to retrieve rconf gem information, check network connectivity' unless version
report_success
report('Latest rconf version is ' + version.blue)
update_rconf(version)
end
@@ -164,14 +191,14 @@
def update_rconf(version)
run_in_all_gemsets do |ruby, gs|
report_check("Checking rconf for #{ruby}@#{gs}")
rconf = Command.execute('rvm', "#{ruby}@#{gs}", 'gem', 'list', 'rconf').output
if rconf =~ /rconf \(#{version}/
- report_success
+ report_success
elsif rconf =~ /^rconf /
report_failure
report_check("Updating rconf for #{ruby}@#{gs}")
- res = Command.execute('rvm', "#{ruby}@#{gs}", 'gem', 'install',
+ res = Command.execute('rvm', "#{ruby}@#{gs}", 'gem', 'install',
'rconf', '-v', version, '--no-ri', '--no-rdoc')
report_result(res.success?)
else
report('SKIPPED (no rconf)')
end