From d362c401ceb5eb7fa740d1207669d75443645bae Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Thu, 25 Feb 2021 02:26:30 +0000 Subject: [PATCH] status: add initialisation date to status This partly addresses https://github.com/DomT4/homebrew-autoupdate/issues/38. --- lib/autoupdate/status.rb | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/autoupdate/status.rb b/lib/autoupdate/status.rb index bff4cd5..8a7fdb6 100644 --- a/lib/autoupdate/status.rb +++ b/lib/autoupdate/status.rb @@ -15,11 +15,30 @@ def autoupdate_not_configured? !File.exist?(Autoupdate::Core.plist) end + def date_of_last_modification + if File.exist?(Autoupdate::Core.location/"brew_autoupdate") + birth = File.birthtime(Autoupdate::Core.location/"brew_autoupdate").to_s + date = Date.parse(birth) + formatted_string = date.strftime("%D") + else + formatted_string = "Unable to determine date of command invocation. Please report this." + end + formatted_string + end + def status if autoupdate_running? - puts "Autoupdate is installed and running." + puts <<~EOS + Autoupdate is installed and running. + + Autoupdate was initialised on #{date_of_last_modification}. + EOS elsif autoupdate_installed_but_stopped? - puts "Autoupdate is installed but stopped." + puts <<~EOS + Autoupdate is installed but stopped. + + Autoupdate was initialised on #{date_of_last_modification}. + EOS elsif autoupdate_not_configured? puts "Autoupdate is not configured. Use `brew autoupdate --start` to begin." else