this repo has no description
56
fork

Configure Feed

Select the types of activity you want to include in your feed.

opts: add group-directories-first

+14 -5
+14 -5
src/main.zig
··· 7 7 8 8 const Options = struct { 9 9 all: bool = false, 10 - almost_all: bool = false, 10 + @"almost-all": bool = false, 11 + @"group-directories-first": bool = true, 11 12 long: bool = false, 13 + 12 14 directory: [:0]const u8 = ".", 13 15 }; 14 16 ··· 38 40 const str = arg[1..]; 39 41 for (str) |b| { 40 42 switch (b) { 41 - 'A' => cmd.opts.almost_all = true, 43 + 'A' => cmd.opts.@"almost-all" = true, 42 44 'a' => cmd.opts.all = true, 43 45 'l' => cmd.opts.long = true, 44 46 else => { ··· 56 58 else if (eql(opt, "long")) 57 59 cmd.opts.long = true 58 60 else if (eql(opt, "almost-all")) 59 - cmd.opts.almost_all = true 61 + cmd.opts.@"almost-all" = true 60 62 else { 61 63 const w = std.io.getStdErr().writer(); 62 64 try w.print("Invalid opt: '{s}'", .{opt}); ··· 131 133 } 132 134 } else { 133 135 for (cmd.entries) |entry| { 134 - try bw.writer().print("{s}\r\n", .{entry.name}); 136 + try bw.writer().print("{s}{s}\r\n", .{ 137 + entry.name, 138 + if (entry.kind == .directory) "/" else "", 139 + }); 135 140 } 136 141 } 137 142 try bw.flush(); ··· 177 182 kind: std.fs.File.Kind, 178 183 statx: ourio.Statx, 179 184 180 - fn lessThan(_: Options, lhs: Entry, rhs: Entry) bool { 185 + fn lessThan(opts: Options, lhs: Entry, rhs: Entry) bool { 186 + if (opts.@"group-directories-first" and lhs.kind != rhs.kind) { 187 + return lhs.kind == .directory; 188 + } 189 + 181 190 return std.ascii.orderIgnoreCase(lhs.name, rhs.name).compare(.lt); 182 191 } 183 192