Class: Nanoc3::CLI::Commands::Update

Inherits:
Nanoc3::CLI::Command show all
Defined in:
lib/nanoc3/cli/commands/update.rb

Instance Attribute Summary

Attributes inherited from Nanoc3::CLI::Command

#arguments, #command, #options

Instance Method Summary collapse

Methods inherited from Nanoc3::CLI::Command

#call, call, #initialize, #site

Constructor Details

This class inherits a constructor from Nanoc3::CLI::Command

Instance Method Details

#runObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/nanoc3/cli/commands/update.rb', line 26

def run
  # Check arguments
  if arguments.size != 0
    $stderr.puts "usage: #{usage}"
    exit 1
  end

  # Make sure we are in a nanoc site directory
  self.require_site

  # Set VCS if possible
  self.set_vcs(options[:vcs])

  # Check for -y switch
  unless options.has_key?(:yes)
    $stderr.puts '*************'
    $stderr.puts '** WARNING **'
    $stderr.puts '*************'
    $stderr.puts
    $stderr.puts 'Are you absolutely sure you want to update the ' +
                 'content for this site? Updating the site content ' +
                 'will change the structure of existing data. This ' +
                 'operation is destructive and cannot be reverted. ' +
                 'Please do not interrupt this operation; doing so can ' +
                 'result in data loss. As always, consider making a ' +
                 'backup copy.'
    $stderr.puts
    $stderr.puts 'If this nanoc site is versioned using a VCS ' +
                 'supported by nanoc, consider using the --vcs option ' +
                 'to have nanoc perform add/delete/move operations ' +
                 'using the specified VCS. To get a list of VCSes ' +
                 'supported by nanoc, issue the "info" command.'
    $stderr.puts
    $stderr.puts 'To continue, use the -y/--yes option, like "nanoc3 ' +
                 'update -y".'
    exit 1
  end

  # Update
  self.site.data_sources.each do |data_source|
    data_source.update
  end
end