diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/tfa/cli.rb | 14 | ||||
| -rw-r--r-- | lib/tfa/version.rb | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/tfa/cli.rb b/lib/tfa/cli.rb index ce6eb01..4493db0 100644 --- a/lib/tfa/cli.rb +++ b/lib/tfa/cli.rb @@ -19,8 +19,20 @@ module TFA end desc "show NAME", "shows the secret for the given key" + method_option :format, default: "raw", enum: ["raw", "qrcode"], desc: "The format to export" def show(name = nil) - name ? storage.secret_for(name) : storage.all.map { |x| x.keys }.flatten.sort + if name + secret = storage.secret_for(name) + case options[:format] + when "qrcode" + require 'rqrcode' + RQRCode::QRCode.new("otpauth://totp/unknown@example.org?secret=#{secret}&issuer=#{name}").as_ansi + else + secret + end + else + storage.all.map { |x| x.keys }.flatten.sort + end end desc "totp NAME", "generate a Time based One Time Password using the secret associated with the given NAME." diff --git a/lib/tfa/version.rb b/lib/tfa/version.rb index 7a2c03d..268b7c3 100644 --- a/lib/tfa/version.rb +++ b/lib/tfa/version.rb @@ -1,3 +1,3 @@ module TFA - VERSION = "0.0.15".freeze + VERSION = "0.0.16".freeze end |
