diff --git a/bin/phraseapp_updater b/bin/phraseapp_updater index 93094e2..c1fec2b 100755 --- a/bin/phraseapp_updater +++ b/bin/phraseapp_updater @@ -9,6 +9,14 @@ class PhraseAppUpdaterCLI < Thor class_option :file_format, type: :string, default: 'json', desc: 'Filetype of localization files.' class_option :verbose, type: :boolean, default: false, desc: 'Verbose output' + # Options that mirror the PhraseApp API (https://developers.phrase.com/api/#post-/projects) + PHRASEAPP_CREATE_PROJECT_OPTIONS = { + zero_plural_form_enabled: { + type: :boolean, + desc: 'Displays the input fields for the \'ZERO\' plural form for every key as well although only some languages require the \'ZERO\' explicitly.' + }, + } + desc 'setup ', 'Create a new PhraseApp project, initializing it with locale files at . the new project ID is printed to STDOUT' method_option :phraseapp_api_key, type: :string, required: true, desc: 'PhraseApp API key.' @@ -16,39 +24,15 @@ class PhraseAppUpdaterCLI < Thor method_option :parent_commit, type: :string, required: true, desc: 'git commit hash of initial locales' method_option :remove_orphans, type: :boolean, default: true, desc: 'Remove keys not in the uploaded default locale' - # Options that mirror the PhraseApp API (https://developers.phrase.com/api/#post-/projects) - method_option :autotranslate_check_new_locales, type: :boolean, desc: 'Requires autotranslate_enabled to be true' - method_option :autotranslate_check_new_translation_keys, type: :boolean, desc: 'Requires autotranslate_enabled to be true' - method_option :autotranslate_check_new_uploads, type: :boolean, desc: 'Requires autotranslate_enabled to be true' - method_option :autotranslate_enabled, type: :boolean, desc: 'Autopilot, requires machine_translation_enabled.' - method_option :autotranslate_mark_as_unverified, type: :boolean, desc: 'Requires autotranslate_enabled to be true' - method_option :autotranslate_use_machine_translation, type: :boolean, desc: 'Requires autotranslate_enabled to be true' - method_option :autotranslate_use_translation_memory, type: :boolean, desc: 'Requires autotranslate_enabled to be true' - method_option :enable_all_data_type_translation_keys_for_translators, type: :boolean, desc: 'Otherwise, translators are not allowed to edit translations other than strings' - method_option :enable_icu_message_format, type: :boolean, desc: 'We can validate and highlight your ICU messages.' - method_option :machine_translation_enabled, type: :boolean, desc: 'Enable machine translation support in the project. Required for Pre-Translation' - method_option :point_of_contact, type: :string, desc: 'User ID of the point of contact for the project.' - method_option :workflow, type: :string, desc: 'Review Workflow. "simple" / "review".' - method_option :zero_plural_form_enabled, type: :boolean, desc: 'Displays the input fields for the \'ZERO\' plural form for every key as well although only some languages require the \'ZERO\' explicitly.' + PHRASEAPP_CREATE_PROJECT_OPTIONS.each do |name, params| + method_option(name, **params) + end def setup(locales_path) validate_readable_path!('locales', locales_path) handle_errors do - phraseapp_opts = options.slice( - :autotranslate_check_new_locales, - :autotranslate_check_new_translation_keys, - :autotranslate_check_new_uploads, - :autotranslate_enabled, - :autotranslate_mark_as_unverified, - :autotranslate_use_machine_translation, - :autotranslate_use_translation_memory, - :enable_all_data_type_translation_keys_for_translators, - :enable_icu_message_format, - :machine_translation_enabled, - :point_of_contact, - :workflow, - :zero_plural_form_enabled) + phraseapp_opts = options.slice(*PHRASEAPP_CREATE_PROJECT_OPTIONS.keys) updater, project_id = PhraseAppUpdater.for_new_project( options[:phraseapp_api_key],