Class: Shoes::UI::CLI::SamplesCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Shoes::UI::CLI::SamplesCommand
- Defined in:
- shoes-core/lib/shoes/ui/cli/samples_command.rb
Instance Attribute Summary collapse
-
#destination_dir ⇒ Object
Returns the value of attribute destination_dir.
Attributes inherited from BaseCommand
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_dir ⇒ Object
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
#help ⇒ Object
33 34 35 36 37 38 39 |
# File 'shoes-core/lib/shoes/ui/cli/samples_command.rb', line 33 def help ("shoes samples [options]", ) + <<-EOS Installs samples to try out. EOS end |
#options ⇒ Object
25 26 27 28 29 30 31 |
# File 'shoes-core/lib/shoes/ui/cli/samples_command.rb', line 25 def OptionParser.new do |opts| opts.on('-dDEST', '--destination=DEST', 'Destination directory') do |destination| self.destination_dir = destination end end end |
#run ⇒ Object
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 |