Class: Rubino::CLI::JobsCommand
- Inherits:
-
Thor
- Object
- Thor
- Rubino::CLI::JobsCommand
- Defined in:
- lib/rubino/cli/jobs_command.rb
Overview
Subcommands for managing the job queue
Class Method Summary collapse
- .exit_on_failure? ⇒ Boolean
-
.render_list(jobs, ui:) ⇒ Object
ONE jobs-table rendering for both surfaces (#187): this CLI verb and the in-chat /jobs list (Commands::Executor).
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
12 13 14 |
# File 'lib/rubino/cli/jobs_command.rb', line 12 def self.exit_on_failure? true end |
.render_list(jobs, ui:) ⇒ Object
ONE jobs-table rendering for both surfaces (#187): this CLI verb and the in-chat /jobs list (Commands::Executor).
46 47 48 49 50 51 52 |
# File 'lib/rubino/cli/jobs_command.rb', line 46 def self.render_list(jobs, ui:) rows = jobs.map do |j| [j[:id][0..7], j[:type], j[:status], j[:attempts].to_s, j[:run_at]] end ui.table(headers: %w[ID Type Status Attempts RunAt], rows: rows) end |
Instance Method Details
#list ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubino/cli/jobs_command.rb', line 23 def list # A present-but-unusable DB (corrupt image, or the duplicate # `schema_info` rows a concurrent first-boot race leaves, #race) must # surface a clean error, not a raw `no such table: jobs` backtrace — # same guard the sessions/memory read CLIs use (#333/#race). if ( = Rubino.) raise Thor::Error, end Rubino.ensure_database_ready! queue = Jobs::Queue.new jobs = queue.list(status: [:status], limit: [:limit]) if jobs.empty? Rubino.ui.info("No jobs found.") return end self.class.render_list(jobs, ui: Rubino.ui) end |