Adds support for handling files and globs as input (#65)

* Added support for handling files as input (#58)

* Added usage case to Travis config (#58)
This commit is contained in:
Tomasz 2017-07-10 13:59:34 +02:00 committed by Athitya Kumar
parent a578f7e5da
commit 10b2198ec8
3 changed files with 9 additions and 2 deletions

View file

@ -19,6 +19,8 @@ script:
- colorls -sf
- colorls -1
- colorls -r
- colorls README.md
- colorls *
install:
- gem install bundler

View file

@ -33,7 +33,12 @@ module ColorLS
private
def init_contents
@contents = Dir.entries(@input) - %w[. ..]
@contents = if Dir.exist?(@input)
Dir.entries(@input) - %w[. ..]
else
[@input]
end
@contents.keep_if { |x| !x.start_with? '.' } unless @all
filter_contents if @show
sort_contents if @sort

View file

@ -19,7 +19,7 @@ module ColorLS
return Core.new(@opts).ls if @args.empty?
@args.each do |path|
next STDERR.puts "\n Specified directory '#{path}' doesn't exist.".colorize(:red) unless Dir.exist?(path)
next STDERR.puts "\n Specified path '#{path}' doesn't exist.".colorize(:red) unless File.exist?(path)
Core.new(path, @opts).ls
end
end