Class: HTTPMe::Command

Inherits:
MisterBin::Command
  • Object
show all
Includes:
Colsole
Defined in:
lib/httpme/command.rb

Instance Method Summary collapse

Instance Method Details

#runObject

Raises:

  • (ArgumentError)


31
32
33
34
35
36
37
38
39
40
41
# File 'lib/httpme/command.rb', line 31

def run
  path = args['PATH'] || ENV['HTTPME_PATH'] || '.'
  port = (args['--port'] || ENV['HTTPME_PORT'] || 3000).to_i
  host = args['--host'] || ENV['HTTPME_HOST'] || '0.0.0.0'
  auth = args['--auth'] || ENV['HTTPME_AUTH']

  raise ArgumentError, "Path not found [#{path}]" unless Dir.exist? path

  server = Server.new path: path, host: host, port: port, auth: auth
  server.run
end