Class: Falcon::Command::Top
- Inherits:
-
Samovar::Command
- Object
- Samovar::Command
- Falcon::Command::Top
- Defined in:
- lib/falcon/command/top.rb
Overview
The top level command for the ‘falcon` executable.
Instance Method Summary collapse
-
#call ⇒ Object
Prepare the environment and invoke the sub-command.
-
#command(value) ⇒ Object
The nested command to execute.
-
#encoding ⇒ Object
The desired external encoding.
-
#quiet? ⇒ Boolean
Whether quiet logging was enabled.
-
#update_external_encoding!(encoding = Encoding::UTF_8) ⇒ Object
Update the external encoding.
-
#verbose? ⇒ Boolean
Whether verbose logging is enabled.
Instance Method Details
#call ⇒ Object
Prepare the environment and invoke the sub-command.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/falcon/command/top.rb', line 74 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 |
#command=(value) ⇒ Object
The nested command to execute.
34 35 36 37 38 39 40 |
# File 'lib/falcon/command/top.rb', line 34 nested :command, { "serve" => Serve, "host" => Host, "virtual" => Virtual, "proxy" => Proxy, "redirect" => Redirect, }, default: "serve" |
#encoding ⇒ Object
The desired external encoding.
67 68 69 70 71 |
# File 'lib/falcon/command/top.rb', line 67 def encoding if name = @options[:encoding] Encoding.find(name) end end |
#quiet? ⇒ Boolean
Whether quiet logging was enabled.
50 51 52 |
# File 'lib/falcon/command/top.rb', line 50 def quiet? @options[:logging] == :quiet end |
#update_external_encoding!(encoding = Encoding::UTF_8) ⇒ Object
Update the external encoding.
If you don’t specify these, it’s possible to have issues when encodings mismatch on the server.
59 60 61 62 63 64 |
# File 'lib/falcon/command/top.rb', line 59 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 |
#verbose? ⇒ Boolean
Whether verbose logging is enabled.
44 45 46 |
# File 'lib/falcon/command/top.rb', line 44 def verbose? @options[:logging] == :verbose end |