Module: Lich::Main::ArgvOptions::SideEffects
- Defined in:
- documented/main/argv_options.rb
Overview
Module for handling side effects of command line options This module applies side effects based on the parsed options.
Class Method Summary collapse
- .execute(argv_options) ⇒ Object
-
.handle_detachable_client(argv_options) ⇒ void
Handles the detachable client option from command line arguments.
-
.handle_hosts_dir(argv_options) ⇒ void
Handles the hosts directory option from command line arguments.
-
.handle_sal_launch(argv_options) ⇒ void
Handles launching the SAL file if specified in options.
Class Method Details
.execute(argv_options) ⇒ Object
248 249 250 251 252 253 |
# File 'documented/main/argv_options.rb', line 248 def self.execute() handle_hosts_dir() handle_detachable_client() handle_sal_launch() end |
.handle_detachable_client(argv_options) ⇒ void
This method modifies the argv_options hash.
This method returns an undefined value.
Handles the detachable client option from command line arguments.
279 280 281 282 283 284 285 286 287 |
# File 'documented/main/argv_options.rb', line 279 def self.handle_detachable_client() [:detachable_client_host] = '127.0.0.1' [:detachable_client_port] = nil if (arg = ARGV.find { |a| a =~ /^\-\-detachable\-client=[0-9]+$/ }) [:detachable_client_port] = /^\-\-detachable\-client=([0-9]+)$/.match(arg).captures.first.to_i elsif (arg = ARGV.find { |a| a =~ /^\-\-detachable\-client=((?:\d{1,3}\.){3}\d{1,3}):([0-9]{1,5})$/ }) [:detachable_client_host], [:detachable_client_port] = /^\-\-detachable\-client=((?:\d{1,3}\.){3}\d{1,3}):([0-9]{1,5})$/.match(arg).captures end end |
.handle_hosts_dir(argv_options) ⇒ void
This method modifies the argv_options hash.
This method returns an undefined value.
Handles the hosts directory option from command line arguments.
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'documented/main/argv_options.rb', line 259 def self.handle_hosts_dir() if (arg = ARGV.find { |a| a == '--hosts-dir' }) i = ARGV.index(arg) ARGV.delete_at(i) hosts_dir = ARGV[i] ARGV.delete_at(i) if hosts_dir && File.exist?(hosts_dir) hosts_dir = hosts_dir.tr('\\', '/') hosts_dir += '/' unless hosts_dir[-1..-1] == '/' [:hosts_dir] = hosts_dir else $stdout.puts "warning: given hosts directory does not exist: #{hosts_dir}" end end end |
.handle_sal_launch(argv_options) ⇒ void
This method may exit the program if the SAL file does not exist.
This method returns an undefined value.
Handles launching the SAL file if specified in options.
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'documented/main/argv_options.rb', line 293 def self.handle_sal_launch() return unless [:sal] unless File.exist?([:sal]) Lich.log "error: launch file does not exist: #{[:sal]}" Lich.msgbox "error: launch file does not exist: #{[:sal]}" exit end Lich.log "info: launch file: #{[:sal]}" if [:sal] =~ /SGE\.sal/i unless (launcher_cmd = Lich.get_simu_launcher) $stdout.puts 'error: failed to find the Simutronics launcher' Lich.log 'error: failed to find the Simutronics launcher' exit end launcher_cmd.sub!('%1', [:sal]) Lich.log "info: launcher_cmd: #{launcher_cmd}" if defined?(Win32) && launcher_cmd =~ /^"(.*?)"\s*(.*)$/ dir_file = $1 param = $2 dir = dir_file.slice(/^.*[\\\/]/) file = dir_file.sub(/^.*[\\\/]/, '') operation = (Win32.isXP? ? 'open' : 'runas') Win32.ShellExecute(lpOperation: operation, lpFile: file, lpDirectory: dir, lpParameters: param) Lich.log "error: Win32.ShellExecute returned #{r}; Win32.GetLastError: #{Win32.GetLastError}" if r < 33 elsif defined?(Wine) system("#{Wine::BIN} #{launcher_cmd}") else system(launcher_cmd) end exit end end |