Sha256: ea8383ab4bf03efdd6fbe88228111ace55c4cf24ebc959455494c5dac6959b74

Contents?: true

Size: 1003 Bytes

Versions: 2

Compression:

Stored size: 1003 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
 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' 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 '!' do |arg|
  Command[:system].call(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

2 entries across 2 versions & 1 rubygems

Version Path
rails-sh-1.2.3 lib/rails/sh/commands.rb
rails-sh-1.2.2 lib/rails/sh/commands.rb