./lib/dubai/commands/serve.rb in dubai-0.0.6 vs ./lib/dubai/commands/serve.rb in dubai-0.1.0

- old
+ new

@@ -4,23 +4,27 @@ c.description = '' c.example 'description', 'pk archive mypass' c.option '-c', '--certificate /path/to/cert.pem', 'Pass certificate' c.option '-p', '--[no]-password', 'Prompt for certificate password' - + c.option '-H', '--host [HOST]', 'Host to bind to' + c.action do |args, options| determine_directory! unless @directory = args.first validate_directory! @certificate = options.certificate validate_certificate! @password = ask("Enter certificate password:"){|q| q.echo = false} if options.password Dubai::Passbook.certificate, Dubai::Passbook.password = @certificate, @password - + Dubai::Server.set :directory, @directory + + Dubai::Server.set :bind, options.host if options.host + Dubai::Server.run! end end # alias_command :serve, :preview @@ -43,7 +47,7 @@ say_error "Directory #{@directory} does not exist" and abort unless File.directory?(@directory) say_error "Directory #{@directory} is not valid pass" and abort unless File.exist?(File.join(@directory, "pass.json")) end def validate_certificate! - say_error "Missing or invalid certificate file" and abort if @certificate.nil? or not File.exist?(@certificate) + say_error "Missing or invalid certificate file" and abort if @certificate.nil? or not File.exist?(@certificate) end