Class: Scheddy::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/scheddy/cli.rb', line 7

def exit_on_failure?
  true
end

Instance Method Details

#startObject



14
15
16
17
# File 'lib/scheddy/cli.rb', line 14

def start
  load_app!
  Scheddy.run
end

#stepdownObject



21
22
23
24
25
# File 'lib/scheddy/cli.rb', line 21

def stepdown
  load_app!
  puts 'Requesting step down...'
  Scheddy::TaskScheduler.leader.first&.request_stepdown
end

#tasksObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/scheddy/cli.rb', line 29

def tasks
  load_app!

  Scheddy.tasks.map do |t|
    OpenStruct.new t.to_h
  end.each do |t|
    puts <<~TASK.gsub(/$\s+$/m,'')
      #{t.type.to_s.humanize} task: #{t.name}
        #{"Interval:       #{t.interval&.inspect}" if t.interval}
        #{"Initial delay:  #{t.initial_delay&.inspect}" if t.initial_delay}
        #{"Cron rule:      #{t.cron}" if t.cron}
        Track runs?     #{t.track_runs}
        Next cycle:     #{t.next_cycle} (if run now)
        Tag:            #{t.tag.present? ? "[#{t.tag}]" : 'nil'}
    TASK
    puts ''
  end
end

#versionObject



50
51
52
# File 'lib/scheddy/cli.rb', line 50

def version
  puts "Scheddy v#{Scheddy::VERSION}"
end