Method: ROTP::CLI#errors

Defined in:
lib/rotp/cli.rb

#errorsObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rotp/cli.rb', line 16

def errors
  if [:time, :hmac].include?(options.mode)
    if options.secret.to_s == ''
      red 'You must also specify a --secret. Try --help for help.'
    elsif options.secret.to_s.chars.any? { |c| ROTP::Base32::CHARS.index(c.downcase) == nil }
      red 'Secret must be in RFC4648 Base32 format - http://en.wikipedia.org/wiki/Base32#RFC_4648_Base32_alphabet'
    end
  elsif options.mode == :hmac && options.counter.to_i < 0
    red 'You must also specify a --counter. Try --help for help.'
  end
end