Skip to content

Commit

Permalink
add almost all option
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-ward committed Jan 2, 2025
1 parent 6fb7b1e commit 5b94316
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

All notable changes to this project will be documented in this file.

## [2025.1 (pending)]
### Added
- add implied . and .. folders to -a option
- almost all option (-A)

## [2024.6]
### Added
- , (comma) flag to print file sizes grouped and separated by thousands.
- --ignore-case option

### Update
- icons
### Updated
- updated icons

## [2024.5]
### Added
Expand Down
13 changes: 12 additions & 1 deletion lsv/format.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ enum Align {
right
}

fn print_files(entries []Entry, options Options) {
fn print_files(entries_arg []Entry, options Options) {
entries := match true {
options.all && !options.almost_all {
dot := make_entry('.', '.', options)
dot_dot := make_entry('..', '.', options)
arrays.concat([dot, dot_dot], ...entries_arg)
}
else {
entries_arg
}
}

w, _ := term.get_terminal_size()
options_width_ok := options.width_in_cols > 0 && options.width_in_cols < 1000
width := if options_width_ok { options.width_in_cols } else { w }
Expand Down
9 changes: 7 additions & 2 deletions lsv/format_long.v
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,20 @@ fn statistics(entries []Entry, len int, options Options) {

size := match true {
// vfmt off
options.size_comma { num_with_commas(total) }
options.size_ki { readable_size(total, true) }
options.size_kb { readable_size(total, false) }
options.size_comma { num_with_commas(total) + ' bytes' }
else { total.str() }
// vfmt on
}

totals := style_string(size, options.style_fi, options)
stats = '${dir_count_styled} ${dirs} | ${file_count_styled} ${files} | ${totals}'
totals_units := if !options.size_ki && !options.size_kb {
style_string('bytes', dim, options)
} else {
''
}
stats = '${dir_count_styled} ${dirs} | ${file_count_styled} ${files} | ${totals} ${totals_units}'

if link_count > 0 {
link_count_styled := style_string(link_count.str(), options.style_ln, options)
Expand Down
5 changes: 4 additions & 1 deletion lsv/options.v
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct Options {
//
// filter, group and sorting options
all bool
almost_all bool
dirs_first bool
only_dirs bool
only_files bool
Expand Down Expand Up @@ -84,6 +85,7 @@ fn parse_args(args []string) Options {
fp.arguments_description('[FILES]')

all := fp.bool('', `a`, false, 'include files starting with .')
almost_all := fp.bool('', `A`, false, 'do not list implied . and ..')
colorize := fp.bool('', `c`, false, 'color the listing')
dir_indicator := fp.bool('', `D`, false, 'append / to directories')
icons := fp.bool('', `i`, false, 'show file icon (requires nerd fonts)')
Expand Down Expand Up @@ -115,8 +117,8 @@ fn parse_args(args []string) Options {
size_kb := fp.bool('', `K`, false, 'sizes in Kilobytes (1000) (e.g. 1kb 234mb 2gb)')
octal_permissions := fp.bool('', `o`, false, 'show octal permissions')
relative_path := fp.bool('', `p`, false, 'show relative path')
accessed_date := fp.bool('', `A`, false, 'show last accessed date')
changed_date := fp.bool('', `C`, false, 'show last status changed date')
accessed_date := fp.bool('', `E`, false, 'show last accessed date')
header := fp.bool('', `H`, false, 'show column headers')
time_iso := fp.bool('', `I`, false, 'show time in iso format')
time_compact := fp.bool('', `J`, false, 'show time in compact format')
Expand Down Expand Up @@ -145,6 +147,7 @@ fn parse_args(args []string) Options {

return Options{
all: all
almost_all: almost_all
accessed_date: accessed_date
blocked_output: blocked_output
changed_date: changed_date
Expand Down

0 comments on commit 5b94316

Please sign in to comment.