class Freshen::CLI
The command line interface class.
Public Instance Methods
info(freshener)
click to toggle source
# File lib/freshen/cli.rb, line 45 def info(freshener) begin Freshener.ensure_installed! freshener rescue Freshen::FreshenerNotInstalled => e puts "#{String.ballot.red} #{e}" exit! 1 end freshener = Freshener.instance_of(freshener) puts freshener.class.name puts " #{freshener.desc}" end
list()
click to toggle source
# File lib/freshen/cli.rb, line 29 def list fresheners = Freshener.all.keys if fresheners.empty? puts "No fresheners are installed" else puts fresheners.join(', ') end end
up(*fresheners)
click to toggle source
# File lib/freshen/cli.rb, line 69 def up(*fresheners) stats = { successful: { color: :green, count: 0 }, skipped: { color: :yellow, count: 0 } } printed_output = false begin duration = Time.duration_of do Freshenary.freshen_up(*fresheners) do |name, freshener, status| case status when Freshenary::Status::FRESHENING print "\n" if printed_output print String.prefix.green puts " Freshening #{freshener.class.name}".bold printed_output = true when Freshenary::Status::CLEANING_UP print "\n" if printed_output print String.prefix.green puts " Cleaning Up #{freshener.class.name}".bold printed_output = true when Freshenary::Status::FRESHENED stats[:successful][:count] += 1 when Freshenary::Status::SKIPPED print "\n" if printed_output print String.prefix.yellow puts " Skipped #{freshener.class.name}".bold printed_output = true stats[:skipped][:count] += 1 end end end stats.delete_if { |key, value| 0 == value[:count] } unless stats.empty? stats = stats.map { |key, value| "#{value[:count]} #{key}".send(value[:color]) } print "\n" if printed_output puts "#{stats.join(" / ")} (%.2f sec)" % duration end rescue Freshen::FreshenerNotInstalled, Freshen::ExecutableError => e print "\n" if printed_output puts "#{String.ballot.red} #{e}" exit! 1 end end
version()
click to toggle source
# File lib/freshen/cli.rb, line 19 def version puts Freshen::VERSION end