Sha256: dced40cf656069096e92ff42919890213c716a7806585e738a82d1e9fd0071db

Contents?: true

Size: 993 Bytes

Versions: 23

Compression:

Stored size: 993 Bytes

Contents

# frozen_string_literal: true

require "project_types/theme/presenters/themes_presenter"

module Theme
  module Forms
    class Select < ShopifyCLI::Form
      attr_accessor :theme
      flag_arguments :root, :title, :exclude_roles, :include_foreign_developments, :cmd

      def ask
        self.theme = CLI::UI::Prompt.ask(title, allow_empty: false) do |handler|
          theme_presenters.each do |presenter|
            theme = presenter.theme

            next if exclude_roles&.include?(theme.role)
            next if !include_foreign_developments && theme.foreign_development?

            handler.option(presenter.to_s(:short)) { theme }
          end
          if handler.options.empty? && cmd
            @ctx.abort(@ctx.message("theme.#{cmd}.no_themes_error"), @ctx.message("theme.#{cmd}.no_themes_resolution"))
          end
        end
      end

      private

      def theme_presenters
        Theme::Presenters::ThemesPresenter.new(ctx, root).all
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

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