bin/nixenvironment in nixenvironment-0.0.10 vs bin/nixenvironment in nixenvironment-0.0.11

- old
+ new

@@ -10,10 +10,41 @@ # :name is optional, otherwise uses the basename of this executable program :name, 'nixenvironment' program :version, VERSION program :description, 'NIX projects build and deploy utility' +global_option ('--project_to_build VALUE') { |value| $project_to_build = value } +global_option ('--project_target_to_build VALUE') { |value| $project_target_to_build = value } +global_option ('--project_target_to_test VALUE') { |value| $project_target_to_test = value } + +global_option ('--workspace_to_build VALUE') { |value| $workspace_to_build = value } +global_option ('--workspace_scheme_to_build VALUE') { |value| $workspace_scheme_to_build = value } +global_option ('--workspace_scheme_to_test VALUE') { |value| $workspace_scheme_to_test = value } + +global_option ('--sdk VALUE') { |value| $sdk = value } +global_option ('--sdk_for_tests VALUE') { |value| $sdk_for_tests = value } + +global_option ('--exclude_pattern_for_code_coverage VALUE') { |value| $exclude_pattern_for_code_coverage = value } +global_option ('--exclude_pattern_for_code_duplication VALUE') { |value| $exclude_pattern_for_code_duplication = value } + +global_option ('--deploy_host VALUE') { |value| $deploy_host = value } +global_option ('--deploy_path VALUE') { |value| $deploy_path = value } +global_option ('--deploy_username VALUE') { |value| $deploy_username = value } +global_option ('--deploy_password VALUE') { |value| $deploy_password = value } + +global_option ('--icons_path VALUE') { |value| $icons_path = value } + +global_option ('--xctest_destination_device VALUE') { |value| $xctest_destination_device = value } + +global_option ('--configuration_files_path VALUE') { |value| $configuration_files_path = value } +global_option ('--code_coverage_configuration VALUE') { |value| $code_coverage_configuration = value } +global_option ('--code_coverage_output_directory VALUE') { |value| $code_coverage_output_directory = value } + +global_option ('--env_var_prefix VALUE') { |value| $env_var_prefix = value } + +global_option ('--infoplist_path VALUE') { |value| $infoplist_path = value } + command :update do |c| c.syntax = 'nixenvironment update' c.description = 'Install or update ninbas and other environment stuff' c.option '--ninbas NAME', String, 'Select ninbas branch, tag or revision to clone' c.action do |args, options| @@ -23,15 +54,15 @@ command :build do |c| c.syntax = 'nixenvironment build [options]' c.description = 'Build project for selected configuration and make signed/resigned ipa' c.option '--config NAME', String, 'Select configuration' - c.option '--ipa NAME', String, 'Select sign' - c.option '--ci_build VALUE', String, 'Define NIXENV_CI_BUILD environment variable' + c.option '--ipa TYPE', String, 'Select sign (ipa, resigned_ipa_for_device, resigned_ipa_for_adhoc_distribution or resigned_ipa_for_appstore)' + c.option '--ci_build VALUE', String, 'Define NIXENV_CI_BUILD environment variable (yes, true, 1 or on to enable)' c.action do |args, options| options.default :config => 'Debug', :ipa => 'ipa', :ci_build => 'yes' - read_config + read_config(options) enable_ci_build(options.ci_build) build_settings = setup(options.config) prebuild(build_settings) build(options.config, options.ipa) revert_info_plist @@ -40,11 +71,11 @@ command :deploy do |c| c.syntax = 'nixenvironment deploy' c.description = 'Deploy built artifacts to given server' c.action do |args, options| - read_config + read_config(options) deploy end end command :clean do |c| @@ -57,29 +88,29 @@ command :test do |c| c.syntax = 'nixenvironment test' c.description = 'Build xctest unit tests and run them in simulator' c.action do |args, options| - read_config + read_config(options) test end end command :code_coverage do |c| c.syntax = 'nixenvironment code_coverage' c.description = 'Generate xctest unit tests code coverage report' c.action do |args, options| - read_config + read_config(options) code_coverage end end command :code_duplication_report do |c| c.syntax = 'nixenvironment code_duplication_report' c.description = 'Generate code duplication report for xctest' c.action do |args, options| - read_config + read_config(options) code_duplication_report end end command :tag do |c| @@ -154,14 +185,45 @@ p(@error_message) if @error_message Dir.chdir(root_working_directory) end end -def read_config +def read_config(options) begin @config = YAML.load(File.read(File.join(File.dirname(__FILE__), 'Config'))) rescue abort('Config file processing error!') + end + + update_config('PROJECT_TO_BUILD', $project_to_build) + update_config('PROJECT_TARGET_TO_BUILD', $project_target_to_build) + update_config('PROJECT_TARGET_TO_TEST', $project_target_to_test) + update_config('WORKSPACE_TO_BUILD', $workspace_to_build) + update_config('WORKSPACE_SCHEME_TO_BUILD', $workspace_scheme_to_build) + update_config('WORKSPACE_SCHEME_TO_TEST', $workspace_scheme_to_test) + update_config('SDK', $sdk) + update_config('SDK_FOR_TESTS', $sdk_for_tests) + update_config('EXCLUDE_PATTERN_FOR_CODE_COVERAGE', $exclude_pattern_for_code_coverage) + update_config('EXCLUDE_PATTERN_FOR_CODE_DUPLICATION', $exclude_pattern_for_code_duplication) + update_config('DEPLOY_HOST', $deploy_host) + update_config('DEPLOY_PATH', $deploy_path) + update_config('DEPLOY_USERNAME', $deploy_username) + update_config('DEPLOY_PASSWORD', $deploy_password) + update_config('ICONS_PATH', $icons_path) + update_config('XCTEST_DESTINATION_DEVICE', $xctest_destination_device) + update_config('CONFIGURATION_FILES_PATH', $configuration_files_path) + update_config('CODE_COVERAGE_CONFIGURATION', $code_coverage_configuration) + update_config('CODE_COVERAGE_OUTPUT_DIRECTORY', $code_coverage_output_directory) + update_config('ENV_VAR_PREFIX', $env_var_prefix) + update_config('INFOPLIST_PATH', $infoplist_path) +end + +def update_config(key, value) + if value + @config[key] = value + p("#{key} |SPECIFIED| directly: #{value}") + else + p("#{key} |NOT specified| directly. Used from Config: #{@config[key]}") end end def enable_ci_build(ci_build) if ci_build == 'yes' or ci_build == 'true' or ci_build == '1' or ci_build == 'on'