Sha256: ba4e99ad225b623b0aa9856a2a35ee25aa1491bbf6e65e8473260ea0b3d6e9b2

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.6.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.5.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.4.1 lib/shopify-cli/commands/create.rb
shopify-cli-1.4.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.3.1 lib/shopify-cli/commands/create.rb
shopify-cli-1.3.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.2.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.1.2 lib/shopify-cli/commands/create.rb
shopify-cli-1.1.1 lib/shopify-cli/commands/create.rb
shopify-cli-1.1.0 lib/shopify-cli/commands/create.rb
shopify-cli-1.0.5 lib/shopify-cli/commands/create.rb