mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-19 05:31:23 +02:00
modify the code according to rubocop
This commit is contained in:
parent
ced1cfebff
commit
ba547f299d
2 changed files with 30 additions and 18 deletions
|
@ -27,8 +27,8 @@ module ColorLS
|
||||||
class Core
|
class Core
|
||||||
def initialize(all: false, sort: false, show: false,
|
def initialize(all: false, sort: false, show: false,
|
||||||
mode: nil, git_status: false, almost_all: false, colors: [], group: nil,
|
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,
|
||||||
indicator_style: 'slash', time_style: '', hard_links_count: true)
|
indicator_style: 'slash', long_style_options: {})
|
||||||
@count = {folders: 0, recognized_files: 0, unrecognized_files: 0}
|
@count = {folders: 0, recognized_files: 0, unrecognized_files: 0}
|
||||||
@all = all
|
@all = all
|
||||||
@almost_all = almost_all
|
@almost_all = almost_all
|
||||||
|
@ -38,13 +38,13 @@ module ColorLS
|
||||||
@group = group
|
@group = group
|
||||||
@show = show
|
@show = show
|
||||||
@one_per_line = mode == :one_per_line
|
@one_per_line = mode == :one_per_line
|
||||||
init_long_format(mode,show_group,show_user)
|
init_long_format(mode,long_style_options)
|
||||||
@tree = {mode: mode == :tree, depth: tree_depth}
|
@tree = {mode: mode == :tree, depth: tree_depth}
|
||||||
@horizontal = mode == :horizontal
|
@horizontal = mode == :horizontal
|
||||||
@git_status = init_git_status(git_status)
|
@git_status = init_git_status(git_status)
|
||||||
@time_style = time_style
|
@time_style = long_style_options.key?(:time_style) ? long_style_options[:time_style] : ''
|
||||||
@indicator_style = indicator_style
|
@indicator_style = indicator_style
|
||||||
@hard_links_count = hard_links_count
|
@hard_links_count = long_style_options.key?(:hard_links_count) ? long_style_options[:hard_links_count] : true
|
||||||
|
|
||||||
init_colors colors
|
init_colors colors
|
||||||
|
|
||||||
|
@ -122,10 +122,10 @@ module ColorLS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def init_long_format(mode, show_group, show_user)
|
def init_long_format(mode, long_style_options)
|
||||||
@long = mode == :long
|
@long = mode == :long
|
||||||
@show_group = show_group
|
@show_group = long_style_options.key?(:show_group) ? long_style_options[:show_group] : true
|
||||||
@show_user = show_user
|
@show_user = long_style_options.key?(:show_user) ? long_style_options[:show_user] : true
|
||||||
end
|
end
|
||||||
|
|
||||||
def init_git_status(show_git)
|
def init_git_status(show_git)
|
||||||
|
|
|
@ -105,11 +105,8 @@ module ColorLS
|
||||||
git_status: false,
|
git_status: false,
|
||||||
colors: [],
|
colors: [],
|
||||||
tree_depth: 3,
|
tree_depth: 3,
|
||||||
show_group: true,
|
|
||||||
show_user: true,
|
|
||||||
indicator_style: 'slash',
|
indicator_style: 'slash',
|
||||||
time_style: '',
|
long_style_options: {}
|
||||||
hard_links_count: true
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -174,21 +171,36 @@ module ColorLS
|
||||||
options.on('-C', 'list entries by columns instead of by lines') { @opts[:mode] = :vertical }
|
options.on('-C', 'list entries by columns instead of by lines') { @opts[:mode] = :vertical }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def default_long_style_options
|
||||||
|
{
|
||||||
|
show_group: true,
|
||||||
|
show_user: true,
|
||||||
|
time_style: '',
|
||||||
|
hard_links_count: true
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def add_long_style_options(options)
|
def add_long_style_options(options)
|
||||||
|
long_style_options = default_long_style_options
|
||||||
options.on('-l', '--long', 'use a long listing format') { @opts[:mode] = :long }
|
options.on('-l', '--long', 'use a long listing format') { @opts[:mode] = :long }
|
||||||
options.on('-o', 'use a long listing format without group information') do
|
options.on('-o', 'use a long listing format without group information') do
|
||||||
@opts[:mode] = :long
|
@opts[:mode] = :long
|
||||||
@opts[:show_group] = false
|
long_style_options[:show_group] = false
|
||||||
end
|
end
|
||||||
options.on('-g', 'use a long listing format without owner information') do
|
options.on('-g', 'use a long listing format without owner information') do
|
||||||
@opts[:mode] = :long
|
@opts[:mode] = :long
|
||||||
@opts[:show_user] = false
|
long_style_options[:show_user] = false
|
||||||
|
end
|
||||||
|
options.on('-G', '--no-group', 'show no group information in a long listing') do
|
||||||
|
long_style_options[:show_group] = false
|
||||||
end
|
end
|
||||||
options.on('-G', '--no-group', 'show no group information in a long listing') { @opts[:show_group] = false }
|
|
||||||
options.on('--time-style=FORMAT', String, 'use time display format') do |time_style|
|
options.on('--time-style=FORMAT', String, 'use time display format') do |time_style|
|
||||||
@opts[:time_style] = time_style
|
long_style_options[:time_style] = time_style
|
||||||
end
|
end
|
||||||
options.on('--no-hardlinks', 'show no hard links count in a long listing') { @opts[:hard_links_count] = false }
|
options.on('--no-hardlinks', 'show no hard links count in a long listing') do
|
||||||
|
long_style_options[:hard_links_count] = false
|
||||||
|
end
|
||||||
|
@opts[:long_style_options] = long_style_options
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_general_options(options)
|
def add_general_options(options)
|
||||||
|
|
Loading…
Reference in a new issue