Sha256: 578796b57fa6b2a4335728f358426db734eb0f36606fc72bdb50f716863dcc88
Contents?: true
Size: 1.46 KB
Versions: 5
Compression:
Stored size: 1.46 KB
Contents
# encoding: utf-8 require_relative '../command' require 'os' module Epuber class Command class Server < Command self.summary = 'Starts web server to display and debug e-book pages.' self.arguments = [ CLAide::Argument.new('TARGET', false, false), ] def self.options [ ['--open', 'Opens the web page in default web browser, working only on OS X'], ].concat(super) end # @param args [CLAide::ARGV] # def initialize(args) super @selected_target_name = args.shift_argument @open_web_browser = args.flag?('open', false) end def validate! super verify_one_bookspec_exists! end def run super require_relative '../server' target = if @selected_target_name.nil? book.buildable_targets.first else book.target_named(@selected_target_name) end help!('Not existing target') if target.nil? begin Epuber::Server.run!(book, target, verbose: verbose?) do |uri| if OS.osx? if @open_web_browser system "open #{uri}" else puts 'Web browser can be automatically opened by adding --open flag, see --help' end end end rescue Interrupt write_lockfile raise end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems