Class: Sshez::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/sshez/runner.rb

Overview

Our main class This will #process the command of the user

Sshez::Runner.new.process(ARGV)

Acts as the listener that the Exec needs

  • :argument_error(Command)

  • :done_with_no_guarantee

  • :permission_error

  • :finished_successfully

Constant Summary collapse

PRINTER =
PrintingManager.instance

Instance Method Summary collapse

Instance Method Details

#argument_error(command) ⇒ Object

Returns the appropriate error messages to the given command



46
47
48
# File 'lib/sshez/runner.rb', line 46

def argument_error(command)
  PRINTER.print(command.error)
end

#done_with_no_guaranteeObject

When no valid command was supplied (maybe only an option)



53
54
55
56
57
# File 'lib/sshez/runner.rb', line 53

def done_with_no_guarantee
  unless PRINTER.output?
    PRINTER.print('Invalid input. Use -h for help')
  end
end

#finished_successfullyObject

We’ve finished everything successfully



32
33
34
# File 'lib/sshez/runner.rb', line 32

def finished_successfully
  PRINTER.print 'Terminated Successfully!'
end

#permission_errorObject

Handles when the config file could not be accessed due to a problem in permissions



39
40
41
# File 'lib/sshez/runner.rb', line 39

def permission_error
  PRINTER.print "Premission denied!\nPlease check your ~/.ssh/config permissions then try again."
end

#process(args) ⇒ Object

Main method of the application takes un processed ARGS and pass it to our parser to start our processing



23
24
25
26
27
# File 'lib/sshez/runner.rb', line 23

def process(args)
  parser = Parser.new(Exec.new(self))
  parser.parse(args)
  PRINTER.output
end