add -G option

This commit is contained in:
t-mangoe 2020-12-05 09:14:12 +09:00
parent 39be15c6aa
commit 0d0a1d96ca
4 changed files with 45 additions and 0 deletions

View file

@ -151,6 +151,7 @@ module ColorLS
@opts[:mode] = :long
@opts[:show_user] = false
end
options.on('-G', '--no-group', 'show no group information in a long listing') { @opts[:show_group] = false }
end
def add_general_options(options)

View file

@ -79,6 +79,10 @@ use a long listing format without group information
use a long listing format without owner information
.
.TP
\fB\-G\fR, \fB\-\-no\-group\fR
show no group information in a long listing
.
.TP
\fB\-\-sd\fR, \fB\-\-sort\-dirs\fR, \fB\-\-group\-directories\-first\fR
sort directories first
.

View file

@ -439,4 +439,42 @@ RSpec.describe ColorLS::Flags do
expect { subject }.not_to output(/user/).to_stdout
end
end
context 'with -G flag in a listing format' do
let(:args) { ['-l', '-G', "#{FIXTURES}/a.txt"] }
before do
fileInfo = instance_double(
'FileInfo',
:group => "sys",
:mtime => Time.now,
:directory? => false,
:owner => "user",
:name => "a.txt",
:show => "a.txt",
:nlink => 1,
:size => 128,
:blockdev? => false,
:chardev? => false,
:socket? => false,
:symlink? => false,
:stats => OpenStruct.new(
mode: 0o444, # read for user, owner, other
setuid?: true,
setgid?: true,
sticky?: true
),
:executable? => false
)
allow(ColorLS::FileInfo).to receive(:new).with("#{FIXTURES}/a.txt", link_info: true) { fileInfo }
end
it 'lists without group info' do
expect { subject }.not_to output(/sys/).to_stdout
end
it 'lists without user info' do
expect { subject }.to output(/user/).to_stdout
end
end
end

View file

@ -24,6 +24,8 @@ _arguments -s -S \
"--long[use a long listing format]" \
"-o[use a long listing format without group information]" \
"-g[use a long listing format without owner information]" \
"-G[show no group information in a long listing]" \
"--no-group[show no group information in a long listing]" \
"--sd[sort directories first]" \
"--sort-dirs[sort directories first]" \
"--group-directories-first[sort directories first]" \