class MiseEnPlace::Parser
Constants
- FLAGS
Public Class Methods
parse(args)
click to toggle source
# File lib/mise_en_place/parser.rb, line 9 def self.parse(args) options = OpenStruct.new opt_parser = OptionParser.new do |opts| opts.banner = "Usage: ProjectCreator [project_title] [options]" opts.separator "" opts.separator "Specific Options:" opts.on("-c", "--config PATH", "Path to your config file") do |path| options.config = Pathname(path) end opts.on("-h", "--help", "Show this message") do puts "" puts opts exit end opts.on("-p", "--project TYPE", "Specify a project type that matches a type in your config file") do |type| options.project_type = type end opts.on_tail("-v", "--version", "Show Version number") do puts VERSION exit end end opt_parser.parse!(args) project_name = args.shift unless valid_project_name? project_name puts "Please specify a project name" exit(false) end options.project_name = project_name options end
Private Class Methods
valid_project_name?(project_name)
click to toggle source
# File lib/mise_en_place/parser.rb, line 49 def self.valid_project_name?(project_name) is_flag = FLAGS.include? project_name does_not_exist = (project_name == nil) return !(is_flag || does_not_exist) end