Add user_tilde method to shorten/anonymize output.

This commit is contained in:
Markus Reiter 2017-02-04 21:52:04 +01:00
parent f0337a3183
commit b54c3d618e

View File

@ -65,10 +65,14 @@ module Hbc
def self.render_env_var(var) def self.render_env_var(var)
if ENV.key?(var) if ENV.key?(var)
var = %Q(#{var}="#{ENV[var]}") var = %Q(#{var}="#{ENV[var]}")
puts var.gsub(ENV["HOME"], "~") puts user_tilde(var)
end end
end end
def self.user_tilde(path)
path.gsub(ENV["HOME"], "~")
end
# This could be done by calling into Homebrew, but the situation # This could be done by calling into Homebrew, but the situation
# where "doctor" is needed is precisely the situation where such # where "doctor" is needed is precisely the situation where such
# things are less dependable. # things are less dependable.
@ -84,7 +88,7 @@ module Hbc
end end
def self.render_staging_location(path) def self.render_staging_location(path)
path = Pathname.new(path) path = Pathname.new(user_tilde(path.to_s))
if !path.exist? if !path.exist?
"#{path} #{error_string "error: path does not exist"}}" "#{path} #{error_string "error: path does not exist"}}"
elsif !path.writable? elsif !path.writable?
@ -95,6 +99,7 @@ module Hbc
end end
def self.render_load_path(paths) def self.render_load_path(paths)
paths.map(&method(:user_tilde))
return "#{none_string} #{error_string}" if [*paths].empty? return "#{none_string} #{error_string}" if [*paths].empty?
paths paths
end end