Class: Shoes::UI::CLI::SamplesCommand

Inherits:
BaseCommand show all
Defined in:
shoes-core/lib/shoes/ui/cli/samples_command.rb

Instance Attribute Summary collapse

Attributes inherited from BaseCommand

#args

Instance Method Summary collapse

Methods inherited from BaseCommand

#help_from_options, #initialize, #parse!, #warn_on_unexpected_parameters

Constructor Details

This class inherits a constructor from Shoes::UI::CLI::BaseCommand

Instance Attribute Details

#destination_dirObject

Returns the value of attribute destination_dir


10
11
12
# File 'shoes-core/lib/shoes/ui/cli/samples_command.rb', line 10

def destination_dir
  @destination_dir
end

Instance Method Details

#helpObject


33
34
35
36
37
38
39
# File 'shoes-core/lib/shoes/ui/cli/samples_command.rb', line 33

def help
  help_from_options("shoes samples [options]",
                    options) + <<-EOS

    Installs samples to try out.
EOS
end

#optionsObject


25
26
27
28
29
30
31
# File 'shoes-core/lib/shoes/ui/cli/samples_command.rb', line 25

def options
  OptionParser.new do |opts|
    opts.on('-dDEST', '--destination=DEST', 'Destination directory') do |destination|
      self.destination_dir = destination
    end
  end
end

#runObject


12
13
14
15
16
17
18
19
20
21
22
23
# File 'shoes-core/lib/shoes/ui/cli/samples_command.rb', line 12

def run
  return unless parse!(args)

  source = Shoes::Samples.path
  destination = File.join((destination_dir || Dir.pwd), "shoes_samples")

  if File.exist?(destination)
    puts "Oops, #{destination} already exists! Try somewhere else, maybe with -d."
  else
    FileUtils.cp_r source, destination
  end
end