Sha256: ebb91c41d8e22437a3b236100c16656688a2a0fb21c387d020fbc7dd004e18e4
Contents?: true
Size: 1.1 KB
Versions: 17
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module Extension module Forms class Register < ShopifyCli::Form flag_arguments :api_key attr_reader :app def ask self.app = ask_app end private attr_writer :app def ask_app if !api_key.nil? found_app = Tasks::GetApp.call(context: ctx, api_key: api_key) ctx.abort(ctx.message('register.invalid_api_key', api_key)) if found_app.nil? found_app else apps = load_apps CLI::UI::Prompt.ask(ctx.message('register.ask_app')) do |handler| apps.each do |app| handler.option("#{app.title} by #{app.business_name}") { app } end end end end def load_apps ctx.puts(@ctx.message('register.loading_apps')) apps = Tasks::GetApps.call(context: ctx) apps.empty? ? abort_no_apps : apps end def abort_no_apps ctx.puts(@ctx.message('register.no_apps')) ctx.puts(@ctx.message('register.learn_about_apps')) raise ShopifyCli::AbortSilent end end end end
Version data entries
17 entries across 17 versions & 1 rubygems