Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #927 from tyabe/add_runner

Add CLI console 'runner' command for run a piece of code
  • Loading branch information...
commit df97bd110e9e9ee558845f26e706e639f695fb65 2 parents b0b128a + e2a2df8
@DAddYE DAddYE authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 padrino-core/lib/padrino-core/cli/base.rb
View
17 padrino-core/lib/padrino-core/cli/base.rb
@@ -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?

0 comments on commit df97bd1

Please sign in to comment.
Something went wrong with that request. Please try again.