add '--indicator-style' option

This commit is contained in:
t-mangoe 2021-05-22 08:39:54 +09:00 committed by Claudio Bley
parent 4bc5d57496
commit 566ea3b45a
3 changed files with 15 additions and 3 deletions

View file

@ -18,7 +18,8 @@ module ColorLS
class Core
def initialize(all: false, sort: false, show: false,
mode: nil, git_status: false, almost_all: false, colors: [], group: nil,
reverse: false, hyperlink: false, tree_depth: nil, show_group: true, show_user: true)
reverse: false, hyperlink: false, tree_depth: nil, show_group: true, show_user: true,
indicator_style: 'slash')
@count = {folders: 0, recognized_files: 0, unrecognized_files: 0}
@all = all
@almost_all = almost_all
@ -32,6 +33,7 @@ module ColorLS
@tree = {mode: mode == :tree, depth: tree_depth}
@horizontal = mode == :horizontal
@git_status = init_git_status(git_status)
@indicator_style = indicator_style
init_colors colors
@ -309,7 +311,7 @@ module ColorLS
logo = value.gsub(/\\u[\da-f]{4}/i) { |m| [m[-4..-1].to_i(16)].pack('U') }
name = content.show
name = make_link(content) if @hyperlink
name += content.directory? ? '/' : ' '
name += content.directory? && @indicator_style != 'none' ? '/' : ' '
entry = "#{out_encode(logo)} #{out_encode(name)}"
entry = entry.bright if !content.directory? && content.executable?

View file

@ -106,7 +106,8 @@ module ColorLS
colors: [],
tree_depth: 3,
show_group: true,
show_user: true
show_user: true,
indicator_style: 'slash'
}
end
@ -141,6 +142,9 @@ module ColorLS
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('--indicator-style=[STYLE]', String, 'append indicator to entry names') do |style|
@opts[:indicator_style] = style
end
end
def add_format_options(options)

View file

@ -544,4 +544,10 @@ RSpec.describe ColorLS::Flags do
expect { subject }.to output(/user/).to_stdout
end
end
context 'with --indicator-style=none' do
let(:args) { ['-dl', '--indicator-style=none', FIXTURES] }
it { expect { subject }.to output(/.+second-level \n.+symlinks \n/).to_stdout }
end
end