Class: Theme::Forms::Select

Inherits:
ShopifyCLI::Form show all
Defined in:
lib/project_types/theme/forms/select.rb

Instance Attribute Summary collapse

Attributes inherited from ShopifyCLI::Form

#ctx, #xargs

Instance Method Summary collapse

Methods inherited from ShopifyCLI::Form

ask, flag_arguments, #initialize, positional_arguments

Constructor Details

This class inherits a constructor from ShopifyCLI::Form

Instance Attribute Details

#themeObject

Returns the value of attribute theme.



8
9
10
# File 'lib/project_types/theme/forms/select.rb', line 8

def theme
  @theme
end

Instance Method Details

#askObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/project_types/theme/forms/select.rb', line 11

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