Sha256: 41bbcdcceab4334ed70a956c3d33a51f8c557f3d50243a0056d3b741def3086f

Contents?: true

Size: 1.34 KB

Versions: 11

Compression:

Stored size: 1.34 KB

Contents

require "shopify_cli"

module ShopifyCli
  module Commands
    class Create < ShopifyCli::Command
      def self.call(args, command_name)
        ProjectType.load_type(args[0]) unless args.empty?
        super
      end

      def call(args, command_name)
        unless args.empty?
          @ctx.puts(@ctx.message("core.create.error.invalid_app_type", args[0]))
          return @ctx.puts(self.class.help)
        end

        type_name = CLI::UI::Prompt.ask(@ctx.message("core.create.project_type_select")) do |handler|
          self.class.all_visible_type.each do |type|
            handler.option(type.project_name) { type.project_type }
          end
        end

        klass = ProjectType.load_type(type_name).create_command
        klass.ctx = @ctx
        klass.call(args, command_name, "create")
      end

      def self.all_visible_type
        ProjectType
          .load_all
          .select { |type| !type.hidden? }
      end

      def self.help
        project_types = all_visible_type.map(&:project_type).sort.join(" | ")
        ShopifyCli::Context.message("core.create.help", ShopifyCli::TOOL_NAME, project_types)
      end

      def self.extended_help
        <<~HELP
          #{
            all_visible_type.map do |type|
              type.create_command.help
            end.join("\n")
          }
        HELP
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shopify-cli-1.14.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.13.1 lib/shopify-cli/commands/create.rb
shopify-cli-1.13.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.12.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.11.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.10.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.9.1 lib/shopify-cli/commands/create.rb
shopify-cli-1.9.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.8.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.7.1 lib/shopify-cli/commands/create.rb
shopify-cli-1.7.0 lib/shopify-cli/commands/create.rb