Sha256: 01bb8071a7912849d0f52e3835ff2fb3bcd0fa9b2953b7a6dbf332cb125ac313

Contents?: true

Size: 979 Bytes

Versions: 1

Compression:

Stored size: 979 Bytes

Contents

include Rails::Sh

Command.define 'help' do
  Rails::Sh.execute_rails_command('--help')
  puts <<HELP

\e[36mThe rails-sh commands are:
 help               print help
 rake TASK          execute rake task
 t, tasks PATTERN   print rake tasks
 exit               exit from rails-sh
 restart            restart rails-sh
 !, system          execute a system command
 eval               eval as ruby script\e[0m
HELP
end

Command.define 'rake' do |arg|
  Rails::Sh::Rake.invoke(arg || :default)
end

Command.define 'tasks', 't' do |arg|
  Rake.application.options.show_task_pattern = arg ? Regexp.new(arg) : //
  Rake.application.display_tasks_and_comments
end

Command.define 'system', '!' do |arg|
  system arg
end

Command.define 'eval' do |arg|
  puts "\e[34m=> #{eval(arg, binding, __FILE__, __LINE__).inspect}\e[0m"
end

Command.define 'restart' do
  puts 'restarting...'
  _exec File.expand_path('../../../../bin/rails-sh', __FILE__)
end

Command.define 'exit' do
  _exit
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-sh-1.2.4 lib/rails/sh/commands.rb