WIP clap
Re-work of https://github.com/eza-community/eza/pull/787 (rebased and cleaned and improved). I tried to minimize the changes, or to reduce the code when that made more sense.
Fix #1364
New help page appearance:
A modern replacement for ls
Usage: eza [OPTIONS] [FILES]
META OPTIONS:
--stdin read file names from stdin
-?, --help Print help
-v, --version Print help
LAYOUT OPTIONS:
-1, --oneline display one entry per line
-l, --long display extended file metadata as a table
-G, --grid display entries as a grid (default)
-x, --across sort the grid across, rather than downwards
-R, --recurse recurse into directories
-T, --tree recurse into directories as a tree
-L, --level <DEPTH> limit the depth of recursion
--follow-symlinks drill down into symbolic links that point to directories
-w, --width <COLS> set screen width in columns
DISPLAY OPTIONS:
-F, --classify [<WHEN>] display type indicator by file names [possible values: always, auto, never]
-X, --dereference dereference symbolic links when displaying information
--absolute [<absolute>] display entries with their absolute path [possible values: on, off, follow]
--color [<WHEN>] When to use colours. [default: auto] [possible values: always, auto, never]
--color-scale [<FIELDS>...] highlight value of FIELDS distinctly [possible values: all, age, size]
--color-scale-mode <MODE> mode for --color-scale [default: gradient] [possible values: fixed, gradient]
--icons [<WHEN>] when to display icons [possible values: always, auto, never]
--hyperlink display entries as hyperlinks
--no-quotes don't quote file names with spaces
FILTERING OPTIONS:
-a, --all... show hidden files. Use this twice to also show the '.' and '..' directories
-A, --almost-all equivalent to --all; included for compatibility with `ls -A`
-d, --list-dirs list directories as files; don't list their contents
-D, --only-dirs list only directories
-f, --only-files list only files
--show-symlinks explicitly show symbolic links (with --only-dirs and --only-files)
--no-symlinks do not show symbolic links
-I, --ignore-glob <GLOBS> glob patterns (pipe-separated) of files to ignore
--git-ignore ignore files mentioned in '.gitignore'
SORTING OPTIONS:
--group-directories-first list directories before other files
--group-directories-last list directories after other files
-s, --sort <FIELD> which field to sort by [default: name] [possible values:
name, Name, .name, .Name, ext, ext, created,
date, age, accessed, changed,
size, inode, type, none]
-r, --reverse reverse the sort order
LONG VIEW OPTIONS:
-h, --header add a header row to each column
-i, --inode list each file's inode number
-o, --octal-permissions list each file's permission in octal format
-H, --links list each file's number of hard links
-b, --binary show file sizes with binary prefixes
-B, --bytes show file sizes in bytes, without any prefixes
--total-size show the size of a directory as the one of its content (unix only)
-S, --blocksize list size of allocated file system blocks
-g, --group list each file's group
--smart-group only show group if it has a different name from owner
-n, --numeric show user and group as their numeric IDs
-t, --time <FIELD> which timestamp field to show [possible values:
mod|modified, acc|accessed, ch|changed, cr|created]
-m, --modified show the modified timestamp field (replace default field, combinable)
-u, --accessed show the accessed timestamp field (replace default field, combinable)
--changed show the changed timestamp field (replace default field, combinable)
-U, --created show the created timestamp field (replace default field, combinable)
--time-style <STYLE> how to format timestamps [possible values:
default, iso, long-iso, full-iso, relative, "+<CUSTOM_FORMAT>"]
-O, --flags list file flags (Mac, BSD, and Windows only)
-Z, --context list each file's security context
--git list each file's Git status, if tracked or ignored
--git-repos list root of git-tree status
--git-repos-no-status list each git-repos branch name (much faster)
-M, --mounts show mount details (Linux and macOS only)
-@, --extended list each file's extended attributes and sizes
--no-permissions suppress the permissions field
--no-filesize suppress the filesize field
--no-user suppress the user field
--no-time suppress the time field
--no-git suppress Git fields (overrides --git, --git-repos, --git-repos-no-status)
- [x] Use builder pattern rather than derive
- [x] Make a nice and compact help
- [x] Find what to do with
--time-styleto both have nice error messages and be able to use a custom string - [x] Make unit tests pass
- [ ] Update integration tests (idk how to yet)
Work to potentially do in another PR:
- Use shadow-rs to reproduce old
--versionbehavior - Handle strict at clap’s level, to simplify code and have more parsing code at the same place
- Move more code from
deducefunctions toparser.rs, to reduce code and remove a level of abstraction in many places - Allow to reset
--color-scale(so that--color-scale all --color-scale age==--color-scale) - (not related to clap) Display an error message when
--time-stylecustom format would make chrono panic
I don’t know what’s wrong with formatting, I used cargo fmt and I’m using rustup so it’s picking up the right version from rust-toolchain.toml. I don’t understand any of the Nix shenanigans so I’m not sure what to look for next…
Looks like some tests are badly formatted according to nix
By the way, first and foremost as I forgot to do it last night, thank you for taking this over as I dont have much time lately to work on this. Also for
Update integration tests (idk how to yet)
You can take a look at https://github.com/eza-community/powertest this was put in place to ease integration testing