Class: Bones::App
- Defined in:
- lib/bones/app.rb,
lib/bones/app/command.rb,
lib/bones/app/file_manager.rb,
lib/bones/app/info_command.rb,
lib/bones/app/create_command.rb,
lib/bones/app/freeze_command.rb,
lib/bones/app/update_command.rb,
lib/bones/app/unfreeze_command.rb
Defined Under Namespace
Classes: Command, CreateCommand, FileManager, FreezeCommand, InfoCommand, UnfreezeCommand, UpdateCommand
Class Method Summary collapse
-
.run(args) ⇒ Object
Create a new instance of App, and run the
bonesapplication given the command line args.
Instance Method Summary collapse
-
#help ⇒ Object
Show the toplevel Mr Bones help message.
-
#initialize(out = STDOUT, err = STDERR) ⇒ App
constructor
Create a new main instance using io for standard output and err for error messages.
-
#run(args) ⇒ Object
Parse the desired user command and run that command object.
Constructor Details
#initialize(out = STDOUT, err = STDERR) ⇒ App
Create a new main instance using io for standard output and err for error messages.
19 20 21 22 |
# File 'lib/bones/app.rb', line 19 def initialize( out = STDOUT, err = STDERR ) @out = out @err = err end |
Class Method Details
.run(args) ⇒ Object
Create a new instance of App, and run the bones application given the command line args.
12 13 14 |
# File 'lib/bones/app.rb', line 12 def self.run( args ) self.new.run args end |
Instance Method Details
#help ⇒ Object
Show the toplevel Mr Bones help message.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/bones/app.rb', line 53 def help @out.puts <<-MSG 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: bones create create a new project from a skeleton bones update copy Mr Bones tasks to a project bones freeze create a new skeleton in ~/.mrbones/ bones unfreeze remove a skeleton from ~/.mrbones/ bones info show information about available skeletons Further Help: Each command has a '--help' option that will provide detailed information for that command. http://codeforpeople.rubyforge.org/bones/ MSG nil end |
#run(args) ⇒ Object
Parse the desired user command and run that command object.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bones/app.rb', line 26 def run( args ) cmd_str = args.shift cmd = case cmd_str when 'create'; CreateCommand.new(@out, @err) when 'update'; UpdateCommand.new(@out, @err) when 'freeze'; FreezeCommand.new(@out, @err) when 'unfreeze'; UnfreezeCommand.new(@out, @err) when 'info'; InfoCommand.new(@out, @err) when nil, '-h', '--help' help when '-v', '--version' @out.puts "Mr Bones #{::Bones::VERSION}" nil else raise "Unknown command #{cmd_str.inspect}" end cmd.run args if cmd rescue StandardError => err @err.puts "ERROR: While executing bones ... (#{err.class})" @err.puts " #{err.to_s}" exit 1 end |