swadhinbiswas Feat:Moved to Rust · 2/15/2026
a330027
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
use clap::Parser;
#[derive(Parser, Debug, Clone)]
#[command(
name = "lsf",
about = "A beautiful ls replacement with Nerd Font icons and colors",
version,
disable_help_flag = true,
disable_version_flag = true,
after_help = "lsf is a fast, native ls replacement written in Rust.\nRequires a Nerd Font installed in your terminal for icons."
)]
pub struct Args {
/// Files or directories to list
#[arg(default_value = ".")]
pub paths: Vec<String>,
/// Use a long listing format
#[arg(short = 'l', long = "long")]
pub long: bool,
/// List all entries including . and ..
#[arg(short = 'a', long = "all")]
pub all: bool,
/// Do not list implied . and ..
#[arg(short = 'A', long = "almost-all")]
pub almost_all: bool,
/// List subdirectories recursively
#[arg(short = 'R', long = "recursive")]
pub recursive: bool,
/// Disable icons
#[arg(long = "no-icons")]
pub no_icons: bool,
/// Sort by file size, largest first
#[arg(short = 'S')]
pub sort_size: bool,
/// Sort by time, newest first
#[arg(short = 't')]
pub sort_time: bool,
/// Sort alphabetically by extension
#[arg(short = 'X')]
pub sort_extension: bool,
/// Do not sort; list entries in directory order
#[arg(short = 'U')]
pub unsorted: bool,
/// Natural sort of (version) numbers within text
#[arg(short = 'v')]
pub version_sort: bool,
/// Reverse order while sorting
#[arg(short = 'r', long = "reverse")]
pub reverse: bool,
/// List entries by lines instead of by columns
#[arg(short = 'x')]
pub across: bool,
/// List one file per line
#[arg(short = '1')]
pub one_per_line: bool,
/// Fill width with a comma separated list of entries
#[arg(short = 'm')]
pub comma: bool,
/// List directories themselves, not their contents
#[arg(short = 'd', long = "directory")]
pub directory: bool,
/// Append indicator (one of */=>@|) to entries
#[arg(short = 'F', long = "classify")]
pub classify: bool,
/// Append / indicator to directories
#[arg(short = 'p')]
pub slash_dirs: bool,
/// Print the allocated number of blocks for each file
#[arg(short = 's', long = "size")]
pub show_size: bool,
/// Print the inode number of each file
#[arg(short = 'i', long = "inode")]
pub inode: bool,
/// With -l: show numeric user and group IDs
#[arg(short = 'n', long = "numeric-uid-gid")]
pub numeric_uid_gid: bool,
/// Like -l, but list owner
#[arg(short = 'o')]
pub long_no_group: bool,
/// Like -l, but do not list owner
#[arg(short = 'g')]
pub long_no_owner: bool,
/// In a long listing, don't print group names
#[arg(short = 'G', long = "no-group")]
pub no_group: bool,
/// Print sizes in human readable format (e.g., 1K 234M 2G)
#[arg(short = 'h', long = "human-readable")]
pub human_readable: bool,
/// Like -h but use powers of 1000
#[arg(long = "si")]
pub si: bool,
/// Follow symbolic links listed on the command line
#[arg(short = 'H', long = "dereference-command-line")]
pub dereference_command_line: bool,
/// Follow all symbolic links
#[arg(short = 'L', long = "dereference")]
pub dereference: bool,
/// Group directories before files
#[arg(long = "group-directories-first")]
pub group_directories_first: bool,
/// End each output line with NUL, not newline
#[arg(long = "zero")]
pub zero: bool,
/// Assume tab stops at each COLS instead of 8
#[arg(short = 'T', long = "tabsize", default_value = "8")]
pub tabsize: usize,
/// Assume the terminal is COLS columns wide
#[arg(short = 'w', long = "width")]
pub term_width: Option<usize>,
/// Do not list entries matching shell PATTERN
#[arg(short = 'I', long = "ignore")]
pub ignore_pattern: Option<String>,
/// Do not list entries ending with ~
#[arg(short = 'B', long = "ignore-backups")]
pub ignore_backups: bool,
/// With -l, print the author of each file
#[arg(long = "author")]
pub author: bool,
/// Colorize the output [auto, always, never]
#[arg(long = "color", default_value = "auto", hide_default_value = true)]
pub color: String,
/// Do not colorize the output (same as --color=never)
#[arg(long = "no-color")]
pub no_color: bool,
/// Print tree view
#[arg(long = "tree")]
pub tree: bool,
/// Set max depth for tree/recursive (0 = unlimited)
#[arg(long = "depth")]
pub max_depth: Option<usize>,
/// Show git status for files (requires git)
#[arg(long = "git")]
pub git: bool,
/// Print help information
#[arg(long = "help")]
pub help: bool,
/// Print version information
#[arg(short = 'V', long = "version")]
pub print_version: bool,
/// Print C-style escapes for nongraphic characters
#[arg(short = 'b', long = "escape")]
pub escape: bool,
/// Do not sort; list entries in directory order (same as -U)
#[arg(short = 'f')]
pub no_sort_all: bool,
/// Emit SELinux / security context
#[arg(short = 'Z', long = "context")]
pub context: bool,
/// Show allocated blocks in -s with this scale
#[arg(long = "block-size")]
pub block_size: Option<String>,
/// Hide entries matching pattern (overridden by -a or -A)
#[arg(long = "hide")]
pub hide_pattern: Option<String>,
}
impl Args {
/// Whether to show hidden files
pub fn show_hidden(&self) -> bool {
self.all || self.almost_all || self.no_sort_all
}
/// Whether to show . and ..
pub fn show_dot_dirs(&self) -> bool {
self.all || self.no_sort_all
}
/// Whether any long-format flag is set
pub fn is_long(&self) -> bool {
self.long || self.long_no_group || self.long_no_owner || self.numeric_uid_gid
}
/// Whether to use color output
pub fn use_color(&self) -> bool {
if self.no_color {
return false;
}
match self.color.as_str() {
"always" | "yes" | "force" => true,
"never" | "no" | "none" => false,
_ => {
// "auto" - check if stdout is a tty
atty_check()
}
}
}
/// Whether sorting is disabled
pub fn no_sort(&self) -> bool {
self.unsorted || self.no_sort_all
}
}
fn atty_check() -> bool {
unsafe { libc::isatty(libc::STDOUT_FILENO) != 0 }
}