bin/action
#!/usr/bin/env ruby
require 'optitron'
require 'fileutils'
require 'actionframework'
require 'json'
require 'httparty'
class String
def black; "\033[30m#{self}\033[0m" end
def red; "\033[31m#{self}\033[0m" end
def green; "\033[32m#{self}\033[0m" end
def brown; "\033[33m#{self}\033[0m" end
def blue; "\033[34m#{self}\033[0m" end
def magenta; "\033[35m#{self}\033[0m" end
def cyan; "\033[36m#{self}\033[0m" end
def gray; "\033[37m#{self}\033[0m" end
def bg_black; "\033[40m#{self}\0330m" end
def bg_red; "\033[41m#{self}\033[0m" end
def bg_green; "\033[42m#{self}\033[0m" end
def bg_brown; "\033[43m#{self}\033[0m" end
def bg_blue; "\033[44m#{self}\033[0m" end
def bg_magenta; "\033[45m#{self}\033[0m" end
def bg_cyan; "\033[46m#{self}\033[0m" end
def bg_gray; "\033[47m#{self}\033[0m" end
def bold; "\033[1m#{self}\033[22m" end
def reverse_color; "\033[7m#{self}\033[27m" end
end
class ActionFrameworkCLI < Optitron::CLI
desc "About ActionFramework"
def about
puts "ActionFramework is a web application framework that tries to be as flexible as sinatra and at the same time have the structure of rails.Enjoy!"
end
desc "Create ActionFramework project"
def new projectname
puts "Creating project directory"
Dir.mkdir("#{projectname}")
puts "Copying project template"
path = ActionFramework::Gem.root.resources.project_template.to_s
FileUtils.cp_r(Dir.glob(path+"/*"),"#{projectname}")
system("cd #{projectname} && bundle install")
puts "Done"
puts "Run \"rackup\" to run your app"
end
desc "Start ActionFramework server"
def s
`rackup`
end
desc "Start ActionFramework console"
def c
$runningserver = ActionFramework::Server.current
puts "Starting ActionFramework IRB"
require 'irb'
ARGV.clear
IRB.start
end
end
ActionFrameworkCLI.dispatch