No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

otp 642B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env ruby
  2. require 'optparse'
  3. require 'otp-cli'
  4. otp = OtpCli::Config.new
  5. OptionParser.new do |opts|
  6. opts.banner = "Usage: #{opts.program_name} [options] <filter>"
  7. opts.on('-a STRING', '--add STRING', 'Add secret from string') do |o|
  8. otp.add o
  9. exit
  10. end
  11. opts.on('-i PATH', '--img PATH', 'Add secret from QR code') do |o|
  12. otp.add_qrcode o
  13. exit
  14. end
  15. opts.on('-q NAME', '--qrcode NAME', 'Display qrcode') do |o|
  16. otp.select(o).qrcode do |f|
  17. system 'display', f.path
  18. end
  19. exit
  20. end
  21. end.parse!
  22. otp = otp.select ARGV[0]
  23. code, delay = otp.code, otp.delay
  24. Clipboard.copy code
  25. $stderr.puts "#{code} (#{delay}s)"