Class: PasswordChanger::Cli::Runner

Inherits:
Thor
  • Object
show all
Defined in:
lib/password_changer/cli/runner.rb

Instance Method Summary collapse

Instance Method Details

#startObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/password_changer/cli/runner.rb', line 21

def start
  PasswordChanger.plugin_manager.activate_plugin(*PasswordChanger.config.plugins)

  PasswordChanger.enable_debug_mode   if options[:debug_mode]
  PasswordChanger.enable_verbose_mode if options[:verbose]

  PluginChecker.check

  data = if options[:csv_file]
           PasswordChanger::Readers::Csv.new.parse(File.expand_path(options[:csv_file]))
         elsif options[:user]
           PasswordChanger::Readers::SingleUser.new.parse(options[:user], options[:ask_new_password])
         else
           fail ArgumentError, 'Please use either `--csv-file`- or `--user`-option.'
         end

  Actions::ChangePassword.new(
    find_printers(options[:output_format]), 
    Changer.new(show_screenshot_on_error: options[:show_screenshot_on_error], viewer_command: options[:viewer_command])
  ).run(data)
end