Class: Zold::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/zold/commands/create.rb

Overview

Create command

Instance Method Summary collapse

Constructor Details

#initialize(wallets:, log: Log::Quiet.new) ⇒ Create

Returns a new instance of Create.


35
36
37
38
# File 'lib/zold/commands/create.rb', line 35

def initialize(wallets:, log: Log::Quiet.new)
  @wallets = wallets
  @log = log
end

Instance Method Details

#run(args = []) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/zold/commands/create.rb', line 40

def run(args = [])
  opts = Slop.parse(args, help: true, suppress_errors: 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.string '--network',
      "The name of the network (default: #{Wallet::MAIN_NETWORK}",
      require: true,
      default: Wallet::MAIN_NETWORK
    o.bool '--help', 'Print instructions'
  end
  mine = Args.new(opts, @log).take || return
  create(mine.empty? ? Id.new : Id.new(mine[0]), opts)
end