Sha256: 79920527da68d8b9b6969ef3ffffd663ff94b0cd4a12ce9f14b4f0b7c5a10529

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module Script
  module Commands
    class Push < ShopifyCli::Command
      options do |parser, flags|
        parser.on('--api_key=APIKEY') { |t| flags[:api_key] = t }
        parser.on('--force') { |t| flags[:force] = t }
      end

      def call(args, _name)
        form = Forms::Push.ask(@ctx, args, options.flags)
        project = ScriptProject.current

        return @ctx.puts(self.class.help) unless form && ScriptProject::SUPPORTED_LANGUAGES.include?(project.language)

        Layers::Application::PushScript.call(
          ctx: @ctx,
          language: project.language,
          extension_point_type: project.extension_point_type,
          script_name: project.script_name,
          source_file: project.source_file,
          api_key: form.api_key,
          force: form.force
        )
        @ctx.puts(@ctx.message('script.push.script_pushed', api_key: form.api_key))
      rescue StandardError => e
        UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.push.error.operation_failed'))
      end

      def self.help
        ShopifyCli::Context.message('script.push.help', ShopifyCli::TOOL_NAME)
      end

      def self.extended_help
        ShopifyCli::Context.message('script.push.extended_help', ShopifyCli::TOOL_NAME)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shopify-cli-1.0.2 lib/project_types/script/commands/push.rb
shopify-cli-1.0.1 lib/project_types/script/commands/push.rb
shopify-cli-1.0.0 lib/project_types/script/commands/push.rb
shopify-cli-0.9.3 lib/project_types/script/commands/push.rb
shopify-cli-0.9.2 lib/project_types/script/commands/push.rb