lib/melodiest/command.rb in melodiest-0.2.1 vs lib/melodiest/command.rb in melodiest-0.3.0

- old
+ new

@@ -3,11 +3,11 @@ module Melodiest class Command def self.parse(options) - args = {name: nil, dir: nil} + args = {} result = "" option_parser = OptionParser.new do |opts| opts.banner = "Usage: melodiest [options]" @@ -21,31 +21,37 @@ opts.on("-nNAME", "--name=NAME", "generate app with name from this option") do |name| args[:name] = name end - opts.on("-dDIR", "--dir=DIR", "instead of current directory, generate app in target DIR") do |dir| - args[:dir] = dir + opts.on("-tDIR", "--target=DIR", "instead of current directory, generate app in target DIR") do |target| + args[:target] = target end + opts.on("-d", "--database", "add sequel orm for postgres sql") do + args[:database] = true + end + end option_parser.parse! options - result = Command.run(args[:name], args[:dir]) unless args[:name].nil? + result = run(args) unless args[:name].nil? result end - def self.run(app_name, target_dir) - generator = Melodiest::Generator.new app_name, target_dir + def self.run(args) + generator = Melodiest::Generator.new args[:name], + destination: args[:target], with_database: args[:database] generator.generate_gemfile generator.generate_bundle_config generator.generate_app + generator.copy_templates - msg = "#{app_name} is successfully generated" - msg << " in #{target_dir}" if target_dir + msg = "#{args[:name]} is successfully generated" + msg << " in #{args[:target]}" if args[:target] msg end end