Sha256: 9ce94198aee9fbaff9d9f53226db49dfaa490bb23ca243d34915e224b1f06f7c
Contents?: true
Size: 1.32 KB
Versions: 22
Compression:
Stored size: 1.32 KB
Contents
module Theme module Forms class Select < ShopifyCLI::Form attr_accessor :theme flag_arguments :root, :title, :exclude_roles, :include_foreign_developments def ask self.theme = CLI::UI::Prompt.ask(title, allow_empty: false) do |handler| themes.each do |theme| next if exclude_roles&.include?(theme.role) next if !include_foreign_developments && theme.foreign_development? handler.option("#{theme.name} #{theme_tags(theme)}") { theme } end end end private def themes @themes ||= ShopifyCLI::Theme::Theme.all(@ctx, root: root) .sort_by { |theme| theme_sort_order(theme) } end def theme_sort_order(theme) case theme.role when "live" 0 when "unpublished" 1 when "development" 2 else 3 end end def theme_tags(theme) color = case theme.role when "live" "green" when "unpublished" "yellow" when "development" "blue" else "italic" end tags = ["{{#{color}:[#{theme.role}]}}"] if theme.current_development? tags << "{{cyan:[yours]}}}}" end tags.join(" ") end end end end
Version data entries
22 entries across 22 versions & 1 rubygems