Skip to content

Commit

Permalink
Merge pull request padrino#927 from tyabe/add_runner
Browse files Browse the repository at this point in the history
Add CLI console 'runner' command for run a piece of code
  • Loading branch information
DAddYE committed Sep 8, 2012
2 parents b0b128a + e2a2df8 commit df97bd1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions padrino-core/lib/padrino-core/cli/base.rb
Expand Up @@ -91,6 +91,23 @@ def version
puts "Padrino v. #{Padrino.version}"
end

desc "runner", "Run a piece of code in the Padrino application environment (alternatively use 'run' or 'r')."
map ["run", "r"] => :runner
def runner(*args)
prepare :runner

code_or_file = args.shift
abort "Please specify code or file" if code_or_file.nil?

require File.expand_path('config/boot.rb')

if File.exist?(code_or_file)
eval(File.read(code_or_file), nil, code_or_file)
else
eval(code_or_file)
end
end

private
def prepare(task)
if options.help?
Expand Down

0 comments on commit df97bd1

Please sign in to comment.