module Piv
  module Helpers
    module Login
      def user_wants_to_preserve_session?(istream = $stdin, ostream = $stdout)
        msg = "#{current_session.name} has already established a session,\
        do you want to start a new session?\e[1m[yN]\e[0m "
        ostream.print msg.squeeze(' ')
        istream.gets.strip !~ /^y$/i
      end

      def ask_for_credentials(istream = $stdin, ostream = $stdout)
        ostream.print "User: "
        user = istream.gets.strip
        ostream.print "Password: "
        password = istream.noecho(&:gets).strip
        puts "\n"

        [user, password]
      end
    end
  end
end

module Piv
  module Helpers
    module Login
      def user_wants_to_preserve_session?
        not yes? <<-MSG.strip_heredoc
#{current_session.user} has already established a session, do you want to start a new session?#{set_color('[yYnN]', nil, :bold)}
        MSG
      end

      def ask_for_credentials
        user = ask "User: ", :add_to_history => true
        password = ask "Password: ", :echo => false
        puts "\n"
        [user, password]
      end
    end
  end
end

Change Piv::Helpers::Login to use thor native prompt methods
Change Piv::Helpers::Login to use thor native prompt methods