Options#print_options: tell don't ask

This commit is contained in:
Olle Jonsson
2017-10-14 21:52:26 +02:00
parent 1fac4efe47
commit 5bb4d51b96
3 changed files with 27 additions and 24 deletions
+17
View File
@@ -1,6 +1,8 @@
# frozen_string_literal: true
require "delegate"
require "github_changelog_generator/helper"
module GitHubChangelogGenerator
# This class wraps Options, and knows a list of known options. Others options
# will raise exceptions.
@@ -90,12 +92,27 @@ module GitHubChangelogGenerator
self[:require].each { |f| require f }
end
# Pretty-prints a censored options hash, if :verbose.
def print_options
return unless self[:verbose]
Helper.log.info "Using these options:"
pp(censored_values)
puts ""
end
private
def values
__getobj__
end
# Returns a censored options hash.
#
# @return [Hash] The GitHub `:token` key is censored in the output.
def censored_values
values.clone.tap { |opts| opts[:token] = opts[:token].nil? ? "No token used" : "hidden value" }
end
def unsupported_options
values.keys - KNOWN_OPTIONS
end