Commit graph

52 commits

Author SHA1 Message Date
t-mangoe
64b1891c2c Set exit status code when specified path doesn't exist
Similar to GNU ls, status code `2` is reported if an argument given on the
command line does not exist.

Close #397
2020-10-07 09:58:01 +02:00
Claudio Bley
52b8c3489d Fix unrecognized files count and colorization
A *file* is assigned a generic icon / glyph in `files.yaml`, so looking up
`:file` in the corresponding hash always succeeds, but `:file` is also used as
the fallback key if a file's extension is not recognized.

First determining the color and group of a given file before falling back to
the `:file` key fixes this issue.
2020-09-07 20:38:42 +02:00
Claudio Bley
8379ba64db Fix newly reported offenses
* Style/MultilineWhenThen: Do not use then for multiline when statement
* Style/StringConcatenation: Prefer string interpolation to string concatenation
* Style/OptionalBooleanParameter: Use keyword arguments when defining method with boolean argument
* Style/GlobalStdStream: Use $stderr instead of STDERR
* Style/GlobalStdStream: Use $stdout instead of STDOUT
2020-09-03 23:18:18 +02:00
Claudio Bley
825e9f711c Only warn if locale settings are broken
Keep running if calling `setlocale` fails, because of invalid locale settings.

Fixes #335.
2020-04-17 00:21:11 +02:00
Claudio Bley
73e4de9378 Use ASCII_8BIT for paths and directory entries
On Unix systems the encoding of file names is specified by the user via the
locale settings.

In order to avoid encoding problems simply read file names in ASCII 8 bit
encoding and try to convert to the external encoding while replacing undefined
characters.

Also, does not show an icon if the external encoding does not support it and
shows a `=` instead of a check mark for git status.

Fixes #352.
2020-04-16 21:58:39 +02:00
Claudio Bley
dfd572310a Add --format=vertical and -C flags
* add and wire up `VerticalLayout` which is now the default
* adapt flags spec to use single-column layout for testing sort order
  since the output is hard to verify when in vertical format

Fixes #189.
2019-07-01 23:27:53 +02:00
Claudio Bley
d528bf18ef Introduce Layout classes and use them
* add `Layout` base class which contains the base (binary) algorithm
  for finding the maximum amount of columns fitting the given limit
* add `HorizontalLayout` and use it in `Core`
* add `SingleColumnLayout` and use it in `Core`
2019-07-01 23:16:33 +02:00
Claudio Bley
97c9570437 Refactor git status handling, add some tests 2019-07-01 22:59:27 +02:00
Claudio Bley
56a0ec6903 Show number of hard links in long listing
Fixes #293
2019-06-30 19:05:00 +02:00
Claudio Bley
3a9e95c653 Use RSpec's output matcher instead of capture_output 2019-03-14 23:50:53 +01:00
Claudio Bley
c0d9266378 Fix spec failures due to calling exit 2019-03-14 23:37:55 +01:00
Claudio Bley
6d6d121553 Add --human-readable option for compatibility with GNU ls
* make `-h` an alias for `--human-readable`
* both options are simply ignored when used with an argument or another option
* running `colorls -h` still shows the help text since just as before
2019-03-14 14:48:19 +01:00
Claudio Bley
6f500722d0 Add String#delete_prefix method for Ruby < 2.5 2019-03-11 23:17:52 +01:00
Alex Cano
c60a2ebec8 Add the option to handle depth for the tree flag (#253)
* Add the option to handle depth for the tree flag

* Update README to describe the new option for the tree flag

* Add tests
2019-01-11 07:36:02 +01:00
Claudio Bley
ce9be74c7a spec: Exclude specs from coverage 2019-01-04 13:45:25 +01:00
Claudio Bley
4033995a83 spec: Avoid failures when STDOUT is no TTY
When using secret variables in Travis CI, the output gets filtered through a
helper process by default (called `redirect_io` strategy) and hence the `STDOUT`
is no longer a real TTY when running the specs. See [1].

[1]: https://github.com/travis-ci/travis-ci/issues/6018
2018-12-28 18:15:27 +01:00
Claudio Bley
6e5a0825d8
Merge pull request #248 from avdv/codecov
Report code coverage to codecov.io
2018-12-28 16:32:50 +01:00
Claudio Bley
9d7d48d48f Report code coverage to codecov.io 2018-12-28 16:28:21 +01:00
Claudio Bley
7a9ea25808
Merge pull request #229 from avdv/socket-chardev-blockdev
Add support for special files
2018-11-12 08:23:51 +01:00
Claudio Bley
4a0ece2908 Add support for special files
Like sockets, character and block devices.
2018-10-21 23:14:21 +02:00
Claudio Bley
f3e9186ee2 Add --format and -x options
Both are also supported by GNU ls, although currently not all formats are
supported.

This change lays ground for implementing column based formatting and also
supports using a pager with colorls keeping the formatting intact:

`colorls --color -x | less --tabs=4 -RFX`
2018-10-20 10:50:30 +02:00
Claudio Bley
8eb0089fc5 Fix spec failure due to big directory size on travis
Listing the fixtures folder sorting by size, expected the files at the beginning
followed by the `symlinks` folder. But on travis, the folder is 4KiB which is
larger than any one of the files.

Keep the folder first by adding the `--group-directories-first` flag.
2018-10-05 22:43:15 +02:00
Claudio Bley
127eb510cd Check whether Etc.getpwuid/getgrid returns nil
On Microsoft Windows, the File.Stat information always has the `uid` and `gid`
set to `0`. Also, the Etc functions simply return `nil`.

Fixes #220.
2018-10-05 22:15:02 +02:00
Claudio Bley
126d8ba164 Fix #205: Handle optparse errors gracefully 2018-08-20 08:00:46 +02:00
Claudio Bley
8428efa010 Add --hyperlink option
This generates `file://` links using ANSI escape sequences which opens the
given file using the default application for the file type on your system.

A terminal emulator supporting hyperlinks is required, otherwise the links
will be ignored.
2018-08-17 23:00:55 +02:00
Claudio Bley
e9944d5f39 Fix #197: Take setuid, setgid and sticky bit into account
These special permission bits should cause the executable bit in the current
group to be replaced with an uppercase letter if the executable bit itself is
*not* set, with a lower case character otherwise.
2018-08-17 18:04:15 +02:00
Claudio Bley
f979ce281c spec: Use multi-line regex mode for matching
This avoids test failures on small terminals (e.g. on Travis) when multiple
lines are generated.
2018-08-12 16:22:27 +02:00
Claudio Bley
012aeb8493 Add -X / --sort=extension flags
This allows the listing to be sorted alphabetically by file extension.

Fixes #199.
2018-08-12 16:22:27 +02:00
Claudio Bley
c78bf3bd73 Add SimpleCov code coverage tool
See [SimpleCov](https://github.com/colszowka/simplecov).
2018-01-11 11:32:44 +01:00
Claudio Bley
038c15f53c Interprete path with trailing slash as a directory 2018-01-02 11:02:36 +01:00
Alex
1cd2029126 Create yaml class and add class methods. Move specs to appropriate folder. Fix method calls. Move flags spec to appropriate folder for rubocop 2017-11-07 19:22:37 -05:00
Alex
7aec4fda94 Add rubocop-rspec as a dev dependency. Fix non-directory changing fixes 2017-11-07 19:22:37 -05:00
Matthew Vincent
ba257b970b Add support for sorting by size
* add `--sort=size` flag
* add `-S` flag
* adjust `.travis.yml` to check the new flags
2017-11-07 22:38:42 +01:00
Claudio Bley
25b21c442a Add support for reverse sorting
Re-assign the `-r` short option from `--report` to `--reverse` and mention this
change in the post install message.
2017-11-07 22:38:42 +01:00
Claudio Bley
dcf5951167 Add test for --sort=time 2017-11-07 22:38:42 +01:00
Claudio Bley
d48f545344 Sort output by default and re-enable test
When not using any sort options, sort the output by name.

This is in line with what `ls` does, too.

Revert "Disable failing test"

This reverts commit 9e41d60956.
2017-11-01 09:07:34 +01:00
Henré Botha
9e41d60956 Disable failing test 2017-10-23 15:25:27 +02:00
Henré Botha
c866b12d8c Reduce redundancy in flag tests 2017-10-22 23:01:23 +02:00
Henré Botha
30ac4ac7ba Capture STDOUT for testing 2017-10-22 23:01:23 +02:00
Henré Botha
e88a786a13 Use rspec-its 2017-10-22 23:01:23 +02:00
Henré Botha
ca6c073252 Add specs for remaining flags 2017-10-22 23:01:23 +02:00
Henré Botha
ece9260855 Add specs for type & sorting flags 2017-10-22 23:01:23 +02:00
Henré Botha
a79673078a Add specs for --all & --report flags 2017-10-22 23:01:23 +02:00
Henré Botha
3b783382f5 Consolidate test files 2017-10-22 23:01:23 +02:00
Claudio Bley
438aed19bd Fix long listing of files as arguments
The elements in `@contents` should only ever be names of directory entries.
Otherwise erroneous paths will be constructed with `@input/@content_entry`.

* add check to ensure that long listing prints information about `.hidden-file`

Fixes #104.
2017-08-21 08:42:02 +02:00
Claudio Bley
6fa9ca2112 Only filter hidden files when listing a directory
* add `.hidden-file` to fixtures
* add check that `.hidden-file` is found to .travis.yml

Fixes #101.
2017-08-18 08:41:47 +02:00
Oskar
1565333cb8 Adds symlink display for -l (#77) 2017-07-12 20:15:23 +05:30
Ace Dimasuhid
d62da43586 Adds -A flag, edits -a flag (#75)
Changes:

* Add -A | --almost-all flag

* Update functionality for -a | --all
2017-07-11 16:08:29 +05:30
Ace Dimasuhid
b8fac358c6 Cleans up YAML specs (#64) 2017-07-10 16:43:39 +05:30
Ace Dimasuhid
67f29c278f Update file_aliases.yaml to reflect sorted version 2017-07-10 00:13:14 +08:00