Sha256: 045d978a43337366512f34b2610b7de1b908488bd7fc5a272a10ac855c43f619
Contents?: true
Size: 1.83 KB
Versions: 10
Compression:
Stored size: 1.83 KB
Contents
# frozen_string_literal: true require "shopify_cli/theme/theme" require "shopify_cli/theme/development_theme" module Theme class Command class Delete < ShopifyCLI::Command::SubCommand options do |parser, flags| parser.on("-d", "--development") { flags[:development] = true } parser.on("-a", "--show-all") { flags[:show_all] = true } parser.on("-f", "--force") { flags[:force] = true } end def call(args, _name) themes = if options.flags[:development] [ShopifyCLI::Theme::DevelopmentTheme.new(@ctx)] elsif args.any? args.map { |id| ShopifyCLI::Theme::Theme.new(@ctx, id: id) } else form = Forms::Select.ask( @ctx, [], title: @ctx.message("theme.delete.select"), exclude_roles: ["live"], include_foreign_developments: options.flags[:show_all], ) return unless form [form.theme] end deleted = 0 themes.each do |theme| if theme.live? @ctx.puts(@ctx.message("theme.delete.live", theme.id)) next elsif !confirm?(theme) next end theme.delete deleted += 1 rescue ShopifyCLI::API::APIRequestNotFoundError @ctx.puts(@ctx.message("theme.delete.not_found", theme.id)) end @ctx.done(@ctx.message("theme.delete.done", deleted)) end def self.help ShopifyCLI::Context.message("theme.delete.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME) end private def confirm?(theme) Forms::ConfirmStore.ask( @ctx, [], title: @ctx.message("theme.delete.confirm", theme.name, theme.shop), force: options.flags[:force], ).confirmed? end end end end
Version data entries
10 entries across 10 versions & 1 rubygems