twik-ruby/lib/twik/cli.rb

31 lines
524 B
Ruby
Raw Normal View History

2014-10-21 09:23:37 +02:00
require 'twik'
require 'twik/cli/config'
require 'twik/cli/options'
class Twik
class Cli
attr_reader :config
def initialize(args)
@config = Config.new(args)
end
def twik
@twik ||= Twik.new(config.privatekey, length: config.length, type: config.type.to_sym)
end
def run
masterkey = ask('Master key: ')
puts twik.generate(config.tag, masterkey)
end
def ask(prompt)
print prompt
res = STDIN.noecho(&:gets).chomp
puts
res
end
end
end