diff --git a/defaults/liftoffrc b/defaults/liftoffrc index 30d1702..4d74c71 100644 --- a/defaults/liftoffrc +++ b/defaults/liftoffrc @@ -4,6 +4,7 @@ # company: # author: # prefix: +# company_identifier: ############################################################################ configure_git: true diff --git a/lib/liftoff/cli.rb b/lib/liftoff/cli.rb index be0f50e..72c647c 100644 --- a/lib/liftoff/cli.rb +++ b/lib/liftoff/cli.rb @@ -2,11 +2,12 @@ module Liftoff class CLI def initialize(argv) @argv = argv + @options = {} end def run parse_command_line_options - LaunchPad.new.liftoff + LaunchPad.new.liftoff @options end private @@ -17,7 +18,7 @@ def parse_command_line_options def global_options OptionParser.new do |opts| - opts.banner = 'usage: liftoff [-v | --version] [-h | --help]' + opts.banner = 'usage: liftoff [-v | --version] [-h | --help] [config options]' opts.on('-v', '--version', 'Display the version and exit') do puts "Version: #{Liftoff::VERSION}" @@ -28,6 +29,38 @@ def global_options puts opts exit end + + opts.on('--[no-]cocoapods', 'Enable/Disable Cocoapods') do |use_cocoapods| + @options[:use_cocoapods] = use_cocoapods + end + + opts.on('--[no-]git', 'Enable/Disable git') do |configure_git| + @options[:configure_git] = configure_git + end + + opts.on('-t', '--indentation N', 'Set indentation level') do |indentation_level| + @options[:indentation_level] = indentation_level + end + + opts.on('-n', '--name [PROJECT_NAME]', 'Set project name') do |name| + @options[:project_name] = name + end + + opts.on('-c', '--company [COMPANY]', 'Set project company') do |company| + @options[:company] = company + end + + opts.on('-a', '--author [AUTHOR]', 'Set project author') do |author| + @options[:author] = author + end + + opts.on('-p', '--prefix [PREFIX]', 'Set project prefix') do |prefix| + @options[:prefix] = prefix + end + + opts.on('-i', '--identifier [IDENTIFIER]', 'Set project company ID (com.example)') do |identifier| + @options[:company_identifier] = identifier + end end end end diff --git a/lib/liftoff/configuration_parser.rb b/lib/liftoff/configuration_parser.rb index 9ab434f..8ed32a4 100644 --- a/lib/liftoff/configuration_parser.rb +++ b/lib/liftoff/configuration_parser.rb @@ -1,6 +1,10 @@ module Liftoff class ConfigurationParser + def initialize(options) + @options = options + end + def project_configuration @configuration ||= evaluated_configuration end @@ -8,9 +12,10 @@ def project_configuration private def evaluated_configuration - default_configuration. - merge(user_configuration). - merge(local_configuration) + default_configuration + .merge(user_configuration) + .merge(local_configuration) + .merge(@options) end def default_configuration diff --git a/lib/liftoff/launchpad.rb b/lib/liftoff/launchpad.rb index 7bf9581..cb4df71 100644 --- a/lib/liftoff/launchpad.rb +++ b/lib/liftoff/launchpad.rb @@ -1,11 +1,8 @@ module Liftoff class LaunchPad - def initialize - liftoffrc = ConfigurationParser.new.project_configuration + def liftoff(options) + liftoffrc = ConfigurationParser.new(options).project_configuration @config = ProjectConfiguration.new(liftoffrc) - end - - def liftoff if project_exists? perform_project_actions else