DisplayOptions struct controls how files are displayed, sorted, and formatted when listing directory contents. This page covers all available configuration options and how they affect the output.
Overview
DisplayOptions is the primary configuration interface for List. It provides fine-grained control over:- What files to show (hidden files, directory-only)
- How to format output (long format, human-readable sizes)
- Visual styling (colors, icons, classification)
- Sorting and organization
- Recursive behavior
Sources/SwiftListCore/Configuration/DisplayOptions.swift
Core Display Options
all: Bool
Whether to show hidden files (files starting with .).
- Default (all: false)
- With -a flag (all: true)
false
CLI Flag: -a, --all
long: Bool
Whether to use long listing format, showing detailed file information including permissions, owner, group, reference count, size, and modification date.
- Default
- Long format (-l)
false
CLI Flag: -l, --long
Format: permissions owner group refCount size modificationDate filename
oneLine: Bool
Whether to display one file per line. By default, List displays files in a wrapped, multi-column format to fit the terminal width.
- Default (wrapped)
- One per line (-1)
false
CLI Flag: -1, --one-line
humanReadable: Bool
Whether to show human-readable file sizes (KB, MB, GB) instead of bytes. Only applies when used with long format.
- Bytes (default)
- Human-readable (-h)
false
CLI Flag: -h, --human-readable
The
-h flag only affects output when combined with -l (long format).Filtering Options
directoryOnly: Bool
Whether to list directories themselves rather than their contents. Useful when you want to see information about a directory rather than whatβs inside it.
- Default (show contents)
- Directory only (-d)
false
CLI Flag: -d, --directory-only
Visual Enhancement Options
color: Bool
Whether to colorize output based on file type. See Color and Icons for details on the color scheme.
Default: false
CLI Flag: --color
Colors:
- Blue: directories
- Yellow: symbolic links
- Red: executables
- White: regular files
icons: Bool
Whether to show emoji icons representing file types. See Color and Icons for the complete icon set.
Default: false
CLI Flag: --icons
Icons:
- π directories
- π files
- π symbolic links
- βοΈ executables
classify: Bool
Whether to append type indicators to file names:
/for directories*for executables
false
CLI Flag: -F, --classify
Recursive Options
recurse: Bool
Whether to recurse into subdirectories and display their contents.
false
CLI Flag: -R, --recursive
depthLimit: Int?
Maximum recursion depth when using recurse. nil means unlimited depth.
nil (unlimited)
CLI Flag: --depth <number>
The
depthLimit option only applies when recurse is enabled.Sorting Options
sortBy: SortOption
How to sort the file listing. See Sorting for detailed information.
Default: .name
Options:
.name- Sort alphabetically by filename (default).time- Sort by modification time, most recent first.size- Sort by file size, largest first
- Default or no flag: sort by name
-t: sort by time-S: sort by size
Programmatic Usage
When using List as a Swift library, create aDisplayOptions instance:
Combining Options
Options can be combined to create powerful listing commands:Related
- Sorting - Detailed information on sort options
- Color and Icons - Visual indicator reference