dev-cmd/contributions: improve CSV output.

Output messages to stderr when CSV output is enabled.

This allows doing `brew contributions --csv > contributions.csv` to
save the output to a file.
This commit is contained in:
Mike McQuaid 2025-06-10 17:28:21 +01:00
parent 144113318e
commit 8d4395118c
No known key found for this signature in database

View File

@ -88,16 +88,21 @@ module Homebrew
contributions << contributions <<
"#{Utils.pluralize("time", grand_totals[username].values.sum, include_count: true)} (total)" "#{Utils.pluralize("time", grand_totals[username].values.sum, include_count: true)} (total)"
puts [ contributions_string = [
"#{username} contributed", "#{username} contributed",
*contributions.to_sentence, *contributions.to_sentence,
"#{time_period(from:, to: args.to)}.", "#{time_period(from:, to: args.to)}.",
].join(" ") ].join(" ")
if args.csv?
$stderr.puts contributions_string
else
puts contributions_string
end
end end
return unless args.csv? return unless args.csv?
puts $stderr.puts
puts generate_csv(grand_totals) puts generate_csv(grand_totals)
end end