Create a new Main application instance. Options can be passed to configuret he stdout and stderr IO streams (very useful for testing).
# File lib/bones/app.rb, line 26
26: def initialize( opts = {} )
27: opts[:stdout] ||= $stdout
28: opts[:stderr] ||= $stderr
29:
30: @opts = opts
31: @stdout = opts[:stdout]
32: @stderr = opts[:stderr]
33: end
Show the toplevel Mr Bones help message.
# File lib/bones/app.rb, line 72
72: def help
73: msg = NAME bones v#{::Bones.version}DESCRIPTION Mr Bones is a handy tool that builds a skeleton for your new Ruby projects. The skeleton contains some starter code and a collection of rake tasks to ease the management and deployment of your source code. Usage: bones -h/--help bones -v/--version bones command [options] [arguments] Examples: bones create new_project bones freeze -r git://github.com/fudgestudios/bort.git bort bones create -s bort new_rails_project Commands:
74:
75: fmt = lambda { |cmd|
76: if @plugins[cmd] < ::Bones::App::Command
77: msg << " bones %-15s %s\n" % [cmd, @plugins[cmd].summary]
78: end
79: }
80:
81: ary = [:create, :freeze, :unfreeze, :info]
82: ary.each(&fmt)
83: (@plugins.keys - ary).each(&fmt)
84:
85: msg.concat Further Help: Each command has a '--help' option that will provide detailed information for that command. http://github.com/TwP/bones
86:
87: stdout.puts msg
88: end
Parse the desired user command and run that command object.
# File lib/bones/app.rb, line 37
37: def run( args )
38: commands = []
39: @plugins = ::Bones::App.plugins
40: @plugins.each { |k,v| commands << k.to_s if v < ::Bones::App::Command }
41:
42: cmd_str = args.shift
43: cmd = case cmd_str
44: when *commands
45: key = cmd_str.to_sym
46: @plugins[key].new @opts
47: when nil, '-h', '--help'
48: help
49: when '-v', '--version'
50: stdout.puts "Mr Bones v#{::Bones.version}"
51: else
52: raise Error, "Unknown command #{cmd_str.inspect}"
53: end
54:
55: if cmd
56: cmd.parse args
57: cmd.run
58: end
59:
60: rescue Bones::App::Error => err
61: stderr.puts "ERROR: While executing bones ..."
62: stderr.puts " #{err.message}"
63: exit 1
64: rescue StandardError => err
65: stderr.puts "ERROR: While executing bones ... (#{err.class})"
66: stderr.puts " #{err.to_s}"
67: exit 1
68: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.