Skip to content

Commit

Permalink
status: add initialisation date to status
Browse files Browse the repository at this point in the history
This partly addresses #38.
  • Loading branch information
DomT4 committed Feb 25, 2021
1 parent db4e911 commit d362c40
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lib/autoupdate/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d362c40

Please sign in to comment.