Class: Lightstreamer::CLI::Main

Inherits:
Thor
  • Object
show all
Defined in:
lib/lightstreamer/cli/main.rb,
lib/lightstreamer/cli/commands/stream_command.rb

Overview

Implements the ‘lightstreamer stream` command.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.bootstrap(argv) ⇒ Object

This is the initial entry point for the execution of the command-line client. It is responsible for the –version/-v options and then invoking the main application.

Parameters:

  • argv (Array<String>)

    The array of command-line arguments.



13
14
15
16
17
18
19
20
# File 'lib/lightstreamer/cli/main.rb', line 13

def bootstrap(argv)
  if argv.index('--version') || argv.index('-v')
    puts VERSION
    exit
  end

  start argv
end

Instance Method Details

#streamObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/lightstreamer/cli/commands/stream_command.rb', line 22

def stream
  prepare_stream

  puts "Session ID: #{@session.session_id}"

  loop do
    data = @queue.pop

    if data.is_a? Lightstreamer::LightstreamerError
      puts "Error: #{data}"
      break
    end

    puts data
  end
end