lib/zold/commands/create.rb in zold-0.5 vs lib/zold/commands/create.rb in zold-0.6
- old
+ new
@@ -27,34 +27,37 @@
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
# License:: MIT
module Zold
# Create command
class Create
- def initialize(wallets:, pubkey:, log: Log::Quiet.new)
+ def initialize(wallets:, log: Log::Quiet.new)
@wallets = wallets
- @pubkey = pubkey
@log = log
end
def run(args = [])
opts = Slop.parse(args, help: true) do |o|
o.banner = "Usage: zold create [options]
Available options:"
+ o.string '--public-key',
+ 'The location of RSA public key (default: ~/.ssh/id_rsa.pub)',
+ require: true,
+ default: '~/.ssh/id_rsa.pub'
o.bool '--help', 'Print instructions'
end
if opts.help?
@log.info(opts.to_s)
return
end
create(opts.arguments.empty? ? Id.new : Id.new(opts.arguments[0]), opts)
end
- def create(id, _)
+ def create(id, opts)
wallet = @wallets.find(id)
- wallet.init(id, @pubkey)
+ key = Zold::Key.new(file: opts['public-key'])
+ wallet.init(id, key)
@log.info(wallet.id)
- @log.debug("Wallet #{Rainbow(wallet).green} \
-created at #{@wallets.path}")
+ @log.debug("Wallet #{Rainbow(wallet).green} created at #{@wallets.path}")
wallet
end
end
end