mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-12 05:31:14 +02:00
add -G option
This commit is contained in:
parent
39be15c6aa
commit
0d0a1d96ca
4 changed files with 45 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]" \
|
||||
|
|
Loading…
Reference in a new issue