Sha256: 99ced1a375d6546fa4c909eddccab10b64a269b108de39094995af19e44ba940

Contents?: true

Size: 929 Bytes

Versions: 1

Compression:

Stored size: 929 Bytes

Contents

#!/usr/bin/env ruby

require 'lnd/tool'
require 'thor'
require 'yaml'

# CLI class of lnd-tool
class CLI < Thor

  class << self
    def exit_on_failure?
      true
    end
  end

  desc 'capture_htlc --config "Path to configuration file"', 'Capture the HTLC events of LND.'
  option :config, required: true, type: :string
  def capture_htlc
    raise Thor::Error, "config file #{options['config']} does not exist." unless File.exist?(options['config'])
    raise Thor::Error, 'Capture process already running.' if LND::Tool::Daemon.running?

    config = YAML.load_file(options['config'])
    LND::Tool::Daemon.start do
      capture = LND::Tool::HTLCEventCapture.new(config['lnd'])
      capture.start
    end
  end

  desc 'stop_capture', 'Stop capture process.'
  def stop_capture
    raise Thor::Error, 'Capture process not running.' unless LND::Tool::Daemon.running?

    LND::Tool::Daemon.stop
  end

end

CLI.start(ARGV)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lnd-tool-0.1.0 exe/lnd-tool