lib/nanoc3/cli/commands/update.rb in nanoc3-3.2.0a4 vs lib/nanoc3/cli/commands/update.rb in nanoc3-3.2.0b1

- old
+ new

@@ -1,65 +1,42 @@ # encoding: utf-8 -module Nanoc3::CLI::Commands +usage 'update [options]' +summary 'update the data stored by the data source to a newer version' +description <<-EOS +Update the data stored by the data source to a newer format. The format in +which data is stored can change between releases, and even though backward +compatibility is usually preserved, it is often a good idea to store the site +data in a newer format so newer features can be taken advantage of. - class Update < Cri::Command +This command will change data, and it is therefore recommended to make a +backup in case something goes wrong. +EOS - def name - 'update' - end +option :c, :vcs, 'select the VCS to use' +flag :y, :yes, 'update the data without warning' - def aliases - [] - end +run do |opts, args, cmd| + Nanoc3::CLI::Commands::Update.call(opts, args, cmd) +end - def short_desc - 'update the data stored by the data source to a newer version' - end +module Nanoc3::CLI::Commands - def long_desc - 'Update the data stored by the data source to a newer format. The ' + - 'format in which data is stored can change between releases, and ' + - 'even though backward compatibility is usually preserved, it is ' + - 'often a good idea to store the site data in a newer format so newer ' + - 'features can be taken advantage of.' + - "\n" + - 'This command will change data, and it is therefore recommended to ' + - 'make a backup in case something goes wrong.' - end + class Update < ::Nanoc3::CLI::Command - def usage - "nanoc3 update [options]" - end - - def option_definitions - [ - # --vcs - { - :long => 'vcs', :short => 'c', :argument => :required, - :desc => 'select the VCS to use' - }, - # --yes - { - :long => 'yes', :short => 'y', :argument => :forbidden, - :desc => 'updates the data without warning' - } - ] - end - - def run(options, arguments) + def run # Check arguments if arguments.size != 0 $stderr.puts "usage: #{usage}" exit 1 end # Make sure we are in a nanoc site directory - @base.require_site + self.require_site # Set VCS if possible - @base.set_vcs(options[:vcs]) + self.set_vcs(options[:vcs]) # Check for -y switch unless options.has_key?(:yes) $stderr.puts '*************' $stderr.puts '** WARNING **' @@ -83,10 +60,10 @@ 'update -y".' exit 1 end # Update - @base.site.data_sources.each do |data_source| + self.site.data_sources.each do |data_source| data_source.update end end end