mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-15 18:18:41 -09:00
Add CLI options for default sort
This commit is contained in:
parent
900d31f6fd
commit
88c8f13c35
2 changed files with 43 additions and 1 deletions
14
ncdu.pod
14
ncdu.pod
|
|
@ -230,6 +230,20 @@ Set to I<off> to disable the shared size column for directories, I<shared>
|
||||||
to display unique directory sizes as a separate column. These options can also
|
to display unique directory sizes as a separate column. These options can also
|
||||||
be cycled through in the browser with the 'u' key.
|
be cycled through in the browser with the 'u' key.
|
||||||
|
|
||||||
|
=item --sort I<COLUMN>
|
||||||
|
|
||||||
|
Change the default column to sort on. Accepted values are I<disk-usage> (the
|
||||||
|
default), I<name>, I<apparent-size>, I<itemcount> or I<mtime>. The latter only
|
||||||
|
makes sense in extended mode, see C<-e>.
|
||||||
|
|
||||||
|
The column can be suffixed with I<-asc> or I<-desc> to set the order to
|
||||||
|
ascending or descending, respectively. e.g. C<--sort=name-desc> will sort by
|
||||||
|
name in descending order.
|
||||||
|
|
||||||
|
=item --group-directories-first, --no-group-directories-first
|
||||||
|
|
||||||
|
Sort (or not) directories before files.
|
||||||
|
|
||||||
=item --confirm-quit, --no-confirm-quit
|
=item --confirm-quit, --no-confirm-quit
|
||||||
|
|
||||||
Require a confirmation before quitting ncdu. Very helpful when you accidentally
|
Require a confirmation before quitting ncdu. Very helpful when you accidentally
|
||||||
|
|
|
||||||
30
src/main.zig
30
src/main.zig
|
|
@ -305,7 +305,35 @@ pub fn main() void {
|
||||||
else if(opt.is("--hide-graph")) config.show_graph = false
|
else if(opt.is("--hide-graph")) config.show_graph = false
|
||||||
else if(opt.is("--show-percent")) config.show_percent = true
|
else if(opt.is("--show-percent")) config.show_percent = true
|
||||||
else if(opt.is("--hide-percent")) config.show_percent = false
|
else if(opt.is("--hide-percent")) config.show_percent = false
|
||||||
else if(opt.is("--shared-column")) {
|
else if(opt.is("--group-directories-first")) config.sort_dirsfirst = true
|
||||||
|
else if(opt.is("--no-group-directories-first")) config.sort_dirsfirst = false
|
||||||
|
else if(opt.is("--sort")) {
|
||||||
|
var val: []const u8 = args.arg();
|
||||||
|
var ord: ?config.SortOrder = null;
|
||||||
|
if (std.mem.endsWith(u8, val, "-asc")) {
|
||||||
|
val = val[0..val.len-4];
|
||||||
|
ord = .asc;
|
||||||
|
} else if (std.mem.endsWith(u8, val, "-desc")) {
|
||||||
|
val = val[0..val.len-5];
|
||||||
|
ord = .desc;
|
||||||
|
}
|
||||||
|
if (std.mem.eql(u8, val, "name")) {
|
||||||
|
config.sort_col = .name;
|
||||||
|
config.sort_order = ord orelse .asc;
|
||||||
|
} else if (std.mem.eql(u8, val, "disk-usage")) {
|
||||||
|
config.sort_col = .blocks;
|
||||||
|
config.sort_order = ord orelse .desc;
|
||||||
|
} else if (std.mem.eql(u8, val, "apparent-size")) {
|
||||||
|
config.sort_col = .size;
|
||||||
|
config.sort_order = ord orelse .desc;
|
||||||
|
} else if (std.mem.eql(u8, val, "itemcount")) {
|
||||||
|
config.sort_col = .items;
|
||||||
|
config.sort_order = ord orelse .desc;
|
||||||
|
} else if (std.mem.eql(u8, val, "mtime")) {
|
||||||
|
config.sort_col = .mtime;
|
||||||
|
config.sort_order = ord orelse .asc;
|
||||||
|
} else ui.die("Unknown --sort option: {s}.\n", .{val});
|
||||||
|
} else if(opt.is("--shared-column")) {
|
||||||
const val = args.arg();
|
const val = args.arg();
|
||||||
if (std.mem.eql(u8, val, "off")) config.show_shared = .off
|
if (std.mem.eql(u8, val, "off")) config.show_shared = .off
|
||||||
else if (std.mem.eql(u8, val, "shared")) config.show_shared = .shared
|
else if (std.mem.eql(u8, val, "shared")) config.show_shared = .shared
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue