Sha256: caa8f9835529e5c8bcd2bf3a1461d1dee92006c33be8a9ef196466a393a81914

Contents?: true

Size: 1.38 KB

Versions: 30

Compression:

Stored size: 1.38 KB

Contents

require "shopify_cli"

module ShopifyCLI
  module CommandOptions
    module CommandServeOptions
      def self.included(base)
        base.extend(ClassMethods)
        base.class_eval do
          def port
            return ShopifyCLI::Tunnel::PORT.to_s unless options.flags.key?(:port)
            port = options.flags[:port].to_i
            @ctx.abort(@ctx.message("core.app.serve.error.invalid_port", options.flags[:port])) unless port > 0
            port
          end

          def host
            host = options.flags[:host]
            unless host.nil?
              @ctx.abort(@ctx.message("core.app.serve.error.host_must_be_https")) if host.match(/^https/i).nil?
            end
            host
          end

          def no_update
            options.flags[:no_update] || false
          end
        end
      end

      module ClassMethods
        def parse_host_option
          options do |parser, flags|
            parser.on("--host=HOST") do |h|
              flags[:host] = h.gsub('"', "")
            end
          end
        end

        def parse_port_option
          options do |parser, flags|
            parser.on("--port=PORT") { |port| flags[:port] = port }
          end
        end

        def parse_no_update_option
          options do |parser, flags|
            parser.on("--no-update") { flags[:no_update] = true }
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

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