Class: Bones::App::InfoCommand

Inherits:
Command show all
Defined in:
lib/bones/app/info_command.rb

Instance Attribute Summary

Attributes inherited from Command

#options

Instance Method Summary collapse

Methods inherited from Command

#copy_tasks, #initialize, #mrbones_dir, #name, #output_dir, #repository, #skeleton_dir, #standard_options, #verbose?, #with_tasks?

Constructor Details

This class inherits a constructor from Bones::App::Command

Instance Method Details

#parse(args) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bones/app/info_command.rb', line 34

def parse( args )
  std_opts = standard_options

  opts = OptionParser.new
  opts.banner = 'Usage: bones info'

  opts.separator ''
  opts.separator '  Shows information about available skeletons'

  opts.separator ''
  opts.separator '  Common Options:'
  opts.on_tail( '-h', '--help', 'show this message' ) {
    @out.puts opts
    exit
  }

  # parse the command line arguments
  opts.parse! args
end

#run(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bones/app/info_command.rb', line 7

def run( args )
  parse args

  skeleton_dir = File.join(mrbones_dir, 'data')
  skeleton_dir = ::Bones.path('data') unless test(?d, skeleton_dir)

  msg  = "\n"
  msg << "The default project skeleton will be copied from:\n"
  msg << "    " << skeleton_dir << "\n\n"

  fmt = "    %-12s => %s\n"
  msg << "Available projects skeletons are:\n"
  Dir.glob(File.join(mrbones_dir, '*')).sort.each do |fn|
    next if fn =~ %r/\.archive$/
    next if File.basename(fn) == 'data'

    if test(?f, fn)
      msg << fmt % [File.basename(fn), File.read(fn).strip]
    else
      msg << "    " << File.basename(fn) << "\n"
    end
  end

  @out.puts msg
  @out.puts
end