Sha256: 58e7ebd2bdac8dad71bda2913846340ba5b59aa2e30673bf6aed3d629bae89a4
Contents?: true
Size: 831 Bytes
Versions: 1
Compression:
Stored size: 831 Bytes
Contents
require "thor" module TFA class CLI < Thor package_name "TFA" class_option :filename desc "add NAME SECRET", "add a new secret to the database" def add(name, secret) secret = clean(secret) storage.save(name, secret) "Added #{name}" end desc "show NAME", "shows the secret for the given key" def show(name = nil) name ? storage.secret_for(name) : storage.all end desc "totp NAME", "generate a Time based One Time Password" def totp(name = nil) TotpCommand.new(storage).run(name) end private def storage @storage ||= Storage.new(filename: options[:filename] || 'tfa') end def clean(secret) if secret.include?("=") /secret=([^&]*)/.match(secret).captures.first else secret end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tfa-0.0.11 | lib/tfa/cli.rb |