FalconSourceFalconCommandTop

class Top

The top level command for the falcon executable.

Nested

Definitions

nested(:command, { "serve" => Serve, "host" => Host, "virtual" => Virtual, "proxy" => Proxy, "redirect" => Redirect, }, default: "serve")

The nested command to execute.

Signature

attribute Command

Implementation

nested :command, {
	"serve" => Serve,
	"host" => Host,
	"virtual" => Virtual,
	"proxy" => Proxy,
	"redirect" => Redirect,
}, default: "serve"

def verbose?

Whether verbose logging is enabled.

Signature

returns Boolean

Implementation

def verbose?
	@options[:logging] == :verbose
end

def quiet?

Whether quiet logging was enabled.

Signature

returns Boolean

Implementation

def quiet?
	@options[:logging] == :quiet
end

def update_external_encoding!(encoding = Encoding::UTF_8)

Update the external encoding.

If you don't specify these, it's possible to have issues when encodings mismatch on the server.

Signature

parameter encoding Encoding

Defaults to Encoding::UTF_8.

Implementation

def update_external_encoding!(encoding = Encoding::UTF_8)
	if Encoding.default_external != encoding
		Console.logger.warn(self) {"Updating Encoding.default_external from #{Encoding.default_external} to #{encoding}"}
		Encoding.default_external = encoding
	end
end

def encoding

The desired external encoding.

Implementation

def encoding
	if name = @options[:encoding]
		Encoding.find(name)
	end
end

def call

Prepare the environment and invoke the sub-command.

Implementation

def call
	if encoding = self.encoding
		update_external_encoding!(encoding)
	else
		update_external_encoding!
	end
	
	if @options[:version]
		puts "#{self.name} v#{Falcon::VERSION}"
	elsif @options[:help]
		self.print_usage
	else
		@command.call
	end
end