Class: Zold::Invoice
- Inherits:
-
Object
- Object
- Zold::Invoice
- Defined in:
- lib/zold/commands/invoice.rb
Overview
Generate invoice
Instance Method Summary collapse
-
#initialize(wallets:, log: Log::Quiet.new) ⇒ Invoice
constructor
A new instance of Invoice.
- #run(args = []) ⇒ Object
Constructor Details
Instance Method Details
#run(args = []) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/zold/commands/invoice.rb', line 38 def run(args = []) opts = Slop.parse(args, help: true, suppress_errors: true) do |o| o. = "Usage: zold invoice ID [options] Where: 'ID' is the wallet ID of the money receiver Available options:" o.integer '--length', 'The length of the invoice prefix (default: 8)', default: 8 o.bool '--help', 'Print instructions' end mine = Args.new(opts, @log).take || return raise 'Receiver wallet ID is required' if mine[0].nil? id = Zold::Id.new(mine[0]) wallet = @wallets.find(id) raise "Wallet #{id} doesn\'t exist in #{@wallets}, do 'zold pull' first" unless wallet.exists? invoice(wallet, opts) end |