Class: SolidQueueTui::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_queue_tui/cli.rb

Class Method Summary collapse

Class Method Details

.parse_options(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/solid_queue_tui/cli.rb', line 17

def self.parse_options(args)
  options = {}

  OptionParser.new do |opts|
    opts.banner = "Usage: sqtui [options]"
    opts.separator ""
    opts.separator "Options:"

    opts.on("--dev", "Enable hot-reload (watches lib/ for changes)") do
      options[:dev] = true
    end

    opts.on("-v", "--version", "Show version") do
      puts "sqtui v#{SolidQueueTui::VERSION}"
      exit
    end

    opts.on("-h", "--help", "Show this help") do
      puts opts
      puts ""
      puts "Configuration:"
      puts "  Create config/solid_tui.yml with:"
      puts "    database_url: sqlite3:storage/queue.sqlite3"
      puts "    refresh: 2"
      exit
    end
  end.parse!(args)

  options
end

.run(args) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/solid_queue_tui/cli.rb', line 7

def self.run(args)
  options = parse_options(args)
  Application.new(**options).run
rescue Connection::ConnectionError => e
  $stderr.puts "Connection error: #{e.message}"
  exit 1
rescue Interrupt
  exit 0
end