#!/usr/bin/env ruby require 'optparse' puts "\nthe `frankup' command is deprecated and will be removed in 0.5, use `frank server' or the alias `frank up'" begin # try to use bundler if its available require 'bundler' begin Bundler.require rescue Bundler::GemfileNotFound # revert to using local frank install $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib]) end rescue LoadError # revert to using local frank install $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib]) end require 'frank' options = {:server => {}} OptionParser.new do |opts| opts.banner = "Usage: frankup [OPTIONS]\n", "Starts the frank development server using setup.rb\n", "If setup.rb isn\'t found, a webserver will be started and serve up files from the current directory\n\n" opts.separator 'Options:' opts.on('--server [HANDLER]', 'Set the server handler') do |handler| options[:server]['handler'] = handler unless handler.nil? end opts.on('--hostname [HOSTNAME]', 'Set the server hostname') do |hostname| options[:server]['hostname'] = hostname unless hostname.nil? end opts.on('--port [PORT]', 'Set the server port') do |port| options[:server]['port'] = port unless port.nil? end opts.on('--dynamic_folder [FOLDER]', 'Set the dynamic folder') do |folder| options[:dynamic_folder] = folder unless folder.nil? end opts.on('--static_folder [FOLDER]', 'Set the static folder') do |folder| options[:static_folder] = folder unless folder.nil? end opts.on( '-h', '--help', 'Display this help' ) do puts opts exit end end.parse! Frank.bootstrap(Dir.pwd) # setup server from options server_options = options[:server] Frank.server.handler = server_options['handler'] if server_options['handler'] Frank.server.hostname = server_options['hostname'] if server_options['hostname'] Frank.server.port = server_options['port'] if server_options['port'] # setup folder options Frank.dynamic_folder = options[:dynamic_folder] if options[:dynamic_folder] Frank.static_folder = options[:static_folder] if options[:static_folder] Frank.new