Sha256: 90453775ca8a225a2e8820aeadec4f6d669ae80ff629af47b89dfd75b5177a5b

Contents?: true

Size: 1.41 KB

Versions: 49

Compression:

Stored size: 1.41 KB

Contents

require "uri"

module PHP
  module Forms
    class Create < ShopifyCLI::Form
      flag_arguments :name, :organization_id, :shop_domain, :type

      def ask
        self.name ||= CLI::UI::Prompt.ask(ctx.message("php.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("php.forms.create.error.invalid_app_name"))
        end
        formatted_name
      end

      def ask_type
        if type.nil?
          return CLI::UI::Prompt.ask(ctx.message("php.forms.create.app_type.select")) do |handler|
            handler.option(ctx.message("php.forms.create.app_type.select_public")) { "public" }
            handler.option(ctx.message("php.forms.create.app_type.select_custom")) { "custom" }
          end
        end

        unless ShopifyCLI::Tasks::CreateApiClient::VALID_APP_TYPES.include?(type)
          ctx.abort(ctx.message("php.forms.create.error.invalid_app_type", type))
        end
        ctx.puts(ctx.message("php.forms.create.app_type.selected", type))
        type
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/project_types/php/forms/create.rb
shopify-cli-2.35.0 lib/project_types/php/forms/create.rb
shopify-cli-2.34.0 lib/project_types/php/forms/create.rb
shopify-cli-2.33.1 lib/project_types/php/forms/create.rb
shopify-cli-2.33.0 lib/project_types/php/forms/create.rb
shopify-cli-2.32.1 lib/project_types/php/forms/create.rb
shopify-cli-2.32.0 lib/project_types/php/forms/create.rb
shopify-cli-2.31.0 lib/project_types/php/forms/create.rb
shopify-cli-2.30.0 lib/project_types/php/forms/create.rb
shopify-cli-2.29.0 lib/project_types/php/forms/create.rb
shopify-cli-2.28.0 lib/project_types/php/forms/create.rb
shopify-cli-2.27.0 lib/project_types/php/forms/create.rb
shopify-cli-2.26.0 lib/project_types/php/forms/create.rb
shopify-cli-2.25.0 lib/project_types/php/forms/create.rb
shopify-cli-2.24.0 lib/project_types/php/forms/create.rb
shopify-cli-2.23.0 lib/project_types/php/forms/create.rb
shopify-cli-2.22.0 lib/project_types/php/forms/create.rb
shopify-cli-2.21.0 lib/project_types/php/forms/create.rb
shopify-cli-2.20.1 lib/project_types/php/forms/create.rb
shopify-cli-2.20.0 lib/project_types/php/forms/create.rb