Class: SshShort::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/ssh_short/parser.rb

Class Method Summary collapse

Class Method Details

.config_file_exists?Boolean



13
14
15
# File 'lib/ssh_short/parser.rb', line 13

def self.config_file_exists?
  File.exist? SshShort::CONFIG_FILE
end

.parse_configObject



5
6
7
8
9
10
11
# File 'lib/ssh_short/parser.rb', line 5

def self.parse_config
  abort "Error: Cannot find config file #{SshShort::CONFIG_FILE}" unless config_file_exists?
  config = YAML.load_file(SshShort::CONFIG_FILE)
  abort 'Error: Keys directory must be specified' unless config[:keys_dir]
  config[:keys_dir] = File.expand_path(config[:keys_dir])
  config
end

.parse_input(config, args) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/ssh_short/parser.rb', line 17

def self.parse_input(config, args)
  options = self.key_options args, {}
  options = self.alias_option args, options
  options = self.action_options args, options
  options = self.user_options args, options
  options = self.node_options args, options, config[:ip_mask]
  options
end