Module: ShopifyCLI::CommandOptions::CommandServeOptions

Included in:
ShopifyCLI::Commands::App::Serve
Defined in:
lib/shopify_cli/command_options/command_serve_options.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/shopify_cli/command_options/command_serve_options.rb', line 6

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