Class: Zold::Create

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

Overview

Create command

Instance Method Summary collapse

Constructor Details

#initialize(wallets:, log: Log::NULL) ⇒ Create

Returns a new instance of Create.



40
41
42
43
# File 'lib/zold/commands/create.rb', line 40

def initialize(wallets:, log: Log::NULL)
  @wallets = wallets
  @log = log
end

Instance Method Details

#run(args = []) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/zold/commands/create.rb', line 45

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: File.expand_path('~/.ssh/id_rsa.pub')
    o.string '--network',
      "The name of the network (default: #{Wallet::MAINET}",
      require: true,
      default: Wallet::MAINET
    o.bool '--help', 'Print instructions'
  end
  mine = Args.new(opts, @log).take || return
  create(mine.empty? ? Id.new : Id.new(mine[0]), opts)
end