Improve CLI story handling slightly

This commit is contained in:
Alexander Olofsson 2024-09-17 19:28:56 +02:00
parent b7048dc565
commit 3c707d39ec
Signed by: ace
GPG key ID: D439C9470CB04C73

View file

@ -52,7 +52,7 @@ class FicTracker::Cli::Story < Thor
}.compact }.compact
found = FicTracker::Models::Story.where(**search) found = FicTracker::Models::Story.where(**search)
if found.size > 1 && !story.start_with?('*/') if found.count > 1 && !story.start_with?('*/')
puts "Found multiple potential stories for #{story}, please specify which ones to remove using the syntax <backend>/<story>: (use */<story> to remove all)" puts "Found multiple potential stories for #{story}, please specify which ones to remove using the syntax <backend>/<story>: (use */<story> to remove all)"
found.each do |f| found.each do |f|
puts " - #{f.backend_name}/#{f.slug} - #{f}" puts " - #{f.backend_name}/#{f.slug} - #{f}"
@ -69,9 +69,9 @@ class FicTracker::Cli::Story < Thor
desc 'list', 'List all tracked stories' desc 'list', 'List all tracked stories'
def list def list
setup! setup!
info = [['Story', 'Chapters', 'Completed', 'Last Updated'], ['-----','--------','---------','------------']] info = [['Slug', 'Story', 'Chapters', 'Completed', 'Last Updated'], ['----','-----','--------','---------','------------']]
FicTracker::Models::Story.order_by(:name).each do |story| FicTracker::Models::Story.order_by(:name).each do |story|
info << [story.name, story.chapters.size, story.completed?, (story.updated_at || story.published_at).strftime("%F")] info << [story.slug, story.name, story.chapters.size, story.completed?, (story.updated_at || story.published_at).strftime("%F")]
end end
print_table info print_table info
end end