Sha256: b86757ecffa4c193e383d3b4a848d98f5e89a3b927682e533d0d433d3772aad9

Contents?: true

Size: 1.85 KB

Versions: 12

Compression:

Stored size: 1.85 KB

Contents

#!/usr/bin/ruby
curpath = __dir__
require 'rubygems'
require 'optparse'
require 'fileutils'
require 'webrick'

def wrap(s, width=78, indent=11)
	lines = []
	line, s = s[0..indent-2], s[indent..-1]
	s.split(/\s+/).each do |word|
		if line.size + word.size >= width
			lines << line
			line = (" " * (indent)) + word
		else
		 line << " " << word
	 end
	 end
	 lines << line if line
	return lines.join "\n"
end

ARGV.options { |opt|
  opt.summary_indent = ' ' * 2
  opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} [options] ui | cpui DIR | new DIR\n"
  opt.on("Options:")
  opt.on("--help", "-h", "This text") { puts opt; exit }
	opt.on("")
  opt.on(wrap("[new DIR]  scaffolds a sample execution engine. Everything except instances can be removed for default behaviour."))
	opt.on("")
  opt.on(wrap("[cpui DIR] scaffolds a sample html client. New versions might require manual merging if you changed something."))
	opt.on("")
  opt.on(wrap("[ui]       starts a simple static web server with the ui on http://localhost:8080. Use [cpui DIR] if you want stuff in apache or nginx."))
  opt.parse!
}
if ARGV.length == 0 || (ARGV.length == 1 && ARGV[0] != 'ui') || (ARGV.length == 2 && %w(cpui new).include?(ARGV[1])) || ARGV.length > 2
  puts ARGV.options
  exit
end
command = ARGV[0]
dir     = ARGV[1]

if command == 'ui'
  s = WEBrick::HTTPServer.new(:Port => 8080,  :DocumentRoot => "#{curpath}/../cockpit/")
  trap("INT"){ s.shutdown }
  s.start
elsif command == "cpui"
  if !File.exists?(dir)
    FileUtils.cp_r("#{curpath}/../cockpit/",dir)
  else
    puts "Directory already exists."
  end
else
  if !File.exists?(dir)
    FileUtils.cp_r("#{curpath}/server/",dir)
    FileUtils.mkdir("#{dir}/instances") rescue nil
    FileUtils.mkdir("#{dir}/resources") rescue nil
    FileUtils.mkdir("#{dir}/handlerwrappers") rescue nil
  else
    puts "Directory already exists."
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cpee-1.3.226 tools/cpee
cpee-1.3.225 tools/cpee
cpee-1.3.224 tools/cpee
cpee-1.3.223 tools/cpee
cpee-1.3.222 tools/cpee
cpee-1.3.221 tools/cpee
cpee-1.3.220 tools/cpee
cpee-1.3.219 tools/cpee
cpee-1.3.217 tools/cpee
cpee-1.3.216 tools/cpee
cpee-1.3.215 tools/cpee
cpee-1.3.214 tools/cpee