#!/usr/bin/env ruby require 'colorize' require 'optparse' require_relative '../lib/nephos-server/version' require_relative '../lib/nephos-server/bin-helpers' GEMFILE = < err puts "Git Init Error: ".yellow + "git repository not initialized" rescue => err puts "Git Init Error: ".yellow + " #{err.message}" end if $git exec("bundle install") if $build end end def self.main opt case $mode when :controller raise BinError, "Invalid Controller name" if not opt[0].to_s.match(/[\w\-\.]+/) Controller.generate!(opt[0]) when :application if not opt[0].to_s.empty? Application.create_application_dir(opt[0]) puts "Application #{opt[0]} created" Application.move_to_application_dir(opt[0]) end Application.initialize! puts "Application initialized" when :route raise BinError, "Need more arguments (verb url controller method)" if opt.size < 3 Route.generate!(*(opt[0..3])) else puts "nephos-generator --help" end end end end begin opt = OptionParser.new do |opts| opts.banner = "Usage<#{Nephos::VERSION}>: nephos-generator " $git = true opts.on("--no-git", "Disable the git initialization when create new application") do $git = false end $build = true opts.on("--no-build", "Disable the `bundle install` execution when create new application") do $build = false end opts.on("--application", "-a", "Create new application") do $mode = :application end opts.on("--route", "-r", "Create and remove routes") do $mode = :route end opts.on("--controller", "-c", "Create and remove controller") do $mode = :controller end opts.on("--rm", "Remove") do $remove = true end opts.on("--debug", "Enable debugging mode") do $debug = true end opts.on("--test", "Enable testing mode (for nephos developpers)") do $test = true end end.parse! Nephos::Generator.main(opt) rescue BinError => err puts "Error:".red + " #{err.message}" rescue => err puts "Error:".red + " #{err.message}" puts err.backtrace end