mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-19 05:31:23 +02:00
Add the option for a short report
This commit is contained in:
parent
234815d0fc
commit
c4f3885410
2 changed files with 22 additions and 11 deletions
|
@ -77,16 +77,24 @@ module ColorLS
|
|||
ls
|
||||
end
|
||||
|
||||
def display_report
|
||||
puts <<~REPORT
|
||||
def display_report(report_mode)
|
||||
if report_mode == :short
|
||||
puts <<~REPORT
|
||||
|
||||
Found #{@count.values.sum} items in total.
|
||||
\s\s\s\sFolders: #{@count[:folders]}, Files: #{@count[:recognized_files] + @count[:unrecognized_files]}.
|
||||
REPORT
|
||||
.colorize(@colors[:report])
|
||||
else
|
||||
puts <<~REPORT
|
||||
|
||||
\tFolders\t\t\t: #{@count[:folders]}
|
||||
\tRecognized files\t: #{@count[:recognized_files]}
|
||||
\tUnrecognized files\t: #{@count[:unrecognized_files]}
|
||||
REPORT
|
||||
.colorize(@colors[:report])
|
||||
Found #{@count.values.sum} items in total.
|
||||
|
||||
\tFolders\t\t\t: #{@count[:folders]}
|
||||
\tRecognized files\t: #{@count[:recognized_files]}
|
||||
\tUnrecognized files\t: #{@count[:unrecognized_files]}
|
||||
REPORT
|
||||
.colorize(@colors[:report])
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -11,7 +11,7 @@ module ColorLS
|
|||
@light_colors = false
|
||||
|
||||
@opts = default_opts
|
||||
@show_report = false
|
||||
@report_mode = false
|
||||
@exit_status_code = 0
|
||||
|
||||
parse_options
|
||||
|
@ -88,7 +88,7 @@ module ColorLS
|
|||
$stderr.puts "#{dir}: #{e}".colorize(:red)
|
||||
end
|
||||
|
||||
core.display_report if @show_report
|
||||
core.display_report(@report_mode) if @report_mode
|
||||
|
||||
@exit_status_code
|
||||
end
|
||||
|
@ -142,8 +142,11 @@ module ColorLS
|
|||
options.on('-d', '--dirs', 'show only directories') { @opts[:show] = :dirs }
|
||||
options.on('-f', '--files', 'show only files') { @opts[:show] = :files }
|
||||
options.on('--gs', '--git-status', 'show git status for each file') { @opts[:git_status] = true }
|
||||
options.on('--report', 'show brief report') { @show_report = true }
|
||||
options.on('-p', 'append / indicator to directories') { @opts[:indicator_style] = 'slash' }
|
||||
options.on('--report=[WORD]', %w[short long], 'show report') do |word|
|
||||
word ||= :long
|
||||
@report_mode = word.to_sym
|
||||
end
|
||||
options.on(
|
||||
'--indicator-style=[STYLE]',
|
||||
%w[none slash], 'append indicator with style STYLE to entry names: none, slash (-p) (default)'
|
||||
|
|
Loading…
Reference in a new issue