mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-12 05:31:14 +02:00
Adds support for -h / --help flag (#97)
* added help flag * updated .travis.yml * added the list of all use-case commands * changed rubocop * made the necessary minor changes in helplog method and changed rubocop
This commit is contained in:
parent
260d8c4255
commit
d3e0cd3bb8
4 changed files with 29 additions and 4 deletions
|
@ -45,10 +45,10 @@ Metrics/ModuleLength:
|
|||
Max: 200
|
||||
|
||||
Metrics/ClassLength:
|
||||
Max: 250
|
||||
Max: 300
|
||||
|
||||
Metrics/ParameterLists:
|
||||
Max: 10
|
||||
Max: 15
|
||||
|
||||
Style/ParallelAssignment:
|
||||
Enabled: false
|
||||
|
@ -83,7 +83,7 @@ Metrics/AbcSize:
|
|||
Max: 20
|
||||
|
||||
Metrics/MethodLength:
|
||||
Max: 15
|
||||
Max: 20
|
||||
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 7
|
||||
|
|
|
@ -24,6 +24,7 @@ script:
|
|||
- colorls -sd
|
||||
- colorls -sf
|
||||
- colorls -t
|
||||
- colorls -h
|
||||
- colorls spec/fixtures/symlinks
|
||||
- colorls README.md
|
||||
- colorls *
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module ColorLS
|
||||
class Core
|
||||
def initialize(input=nil, all: false, report: false, sort: false, show: false,
|
||||
one_per_line: false, long: false, almost_all: false, tree: false, colors: [])
|
||||
one_per_line: false, long: false, almost_all: false, tree: false, help: false, colors: [])
|
||||
@input = input || Dir.pwd
|
||||
@count = {folders: 0, recognized_files: 0, unrecognized_files: 0}
|
||||
@all = all
|
||||
|
@ -12,6 +12,7 @@ module ColorLS
|
|||
@one_per_line = one_per_line
|
||||
@long = long
|
||||
@tree = tree
|
||||
@help = help
|
||||
@screen_width = ::TermInfo.screen_size.last
|
||||
@colors = colors
|
||||
|
||||
|
@ -23,6 +24,8 @@ module ColorLS
|
|||
def ls
|
||||
return print "\n Nothing to show here\n".colorize(@colors[:empty]) if @contents.empty?
|
||||
|
||||
return helplog if @help
|
||||
|
||||
if @tree
|
||||
print "\n"
|
||||
tree_traverse(@input, 0, 2)
|
||||
|
@ -290,5 +293,25 @@ module ColorLS
|
|||
return prespace_icon if prespace.zero?
|
||||
' │ ' * (prespace/indent) + prespace_icon + '─' * indent
|
||||
end
|
||||
|
||||
def helplog
|
||||
print "\nUsage: colorls <command> [-<attributes> (or) --<attributes>] <path> <keyword>\n\n
|
||||
The available attributes are:\n
|
||||
\t1 list in a line
|
||||
\ta (or) all list inclding hidden files in the directory
|
||||
\tA (or) almost-all list almost all the files
|
||||
\td (or) dirs list directories only
|
||||
\tf (or) files list files only
|
||||
\tl (or) long show list with long format
|
||||
\tr (or) report detailed report of the files
|
||||
\tsd (or) sort-dirs sorted and grouped list of directiories followed by files
|
||||
\tsf (or) sort-files sorted and grouped list of files followed by directiories
|
||||
\tt (or) tree shows tree view of the directory
|
||||
\th (or) help show this page\n\n
|
||||
The available commands are:\n
|
||||
\tREADME.md lists the README file irrespective of current path
|
||||
\t* colorls called recursively for each subsequent directory
|
||||
\t| grep lists the files having the given keyword in the name\n\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,6 +13,7 @@ module ColorLS
|
|||
one_per_line: flag_given?(%w[-1]) || !STDOUT.tty?,
|
||||
long: flag_given?(%w[-l --long]),
|
||||
tree: flag_given?(%w[-t --tree]),
|
||||
help: flag_given?(%w[-h --help]),
|
||||
colors: @colors
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue