Sha256: 6c92667d2f2df807a9ddc34f7dd8087d473c1d12471687cb603cbe237c31b2d5
Contents?: true
Size: 1.45 KB
Versions: 49
Compression:
Stored size: 1.45 KB
Contents
require "uri" module Node module Forms class Create < ShopifyCLI::Form attr_accessor :name flag_arguments :name, :organization_id, :shop_domain, :type def ask self.name ||= CLI::UI::Prompt.ask(ctx.message("node.forms.create.app_name")) self.name = format_name self.type = ask_type res = ShopifyCLI::Tasks::SelectOrgAndShop.call(ctx, organization_id: organization_id, shop_domain: shop_domain) self.organization_id = res[:organization_id] self.shop_domain = res[:shop_domain] end private def format_name formatted_name = name.downcase.split(" ").join("_") if formatted_name.include?("shopify") ctx.abort(ctx.message("node.forms.create.error.invalid_app_name")) end formatted_name end def ask_type if type.nil? return CLI::UI::Prompt.ask(ctx.message("node.forms.create.app_type.select")) do |handler| handler.option(ctx.message("node.forms.create.app_type.select_public")) { "public" } handler.option(ctx.message("node.forms.create.app_type.select_custom")) { "custom" } end end unless ShopifyCLI::Tasks::CreateApiClient::VALID_APP_TYPES.include?(type) ctx.abort(ctx.message("node.forms.create.error.invalid_app_type", type)) end ctx.puts(ctx.message("node.forms.create.app_type.selected", type)) type end end end end
Version data entries
49 entries across 49 versions & 1 rubygems