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:, remotes:, log: Log::NULL) ⇒ Create

Returns a new instance of Create.



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

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

Instance Method Details

#run(args = []) ⇒ Object



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

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.bool '--skip-test',
      'Don\'t check whether this wallet ID is available',
      default: false
    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? ? create_id(opts) : Id.new(mine[0]), opts)
end