|
|
@ -342,6 +342,22 @@ const SearchRunner = struct {
|
|
342
|
342
|
}
|
|
343
|
343
|
};
|
|
344
|
344
|
|
|
|
345
|
const FileRunner = struct {
|
|
|
346
|
fn init() Runner {
|
|
|
347
|
return Runner{ .name = "file", .run_always = true, .toArgv = toArgv, .isActive = isActive };
|
|
|
348
|
}
|
|
|
349
|
|
|
|
350
|
fn isActive(cmd: []const u8) bool {
|
|
|
351
|
return cmd.len > "file ".len and std.mem.startsWith(u8, cmd, "file ");
|
|
|
352
|
}
|
|
|
353
|
|
|
|
354
|
fn toArgv(cmd: []const u8) []const []const u8 {
|
|
|
355
|
// FIXME: replace with choice + selection whenever that is implemented
|
|
|
356
|
_ = std.fmt.bufPrint(&cmd_buf, "find ~/k/the-thing ~/t/zig -type f -name '{s}' | head -n1 | tee /tmp/file-search && ([ \"$(wc -l < /tmp/file-search)\" = \"1\" ] && cat \"$(head -n1 /tmp/file-search)\") || echo \"not found\"\x00", .{cmd["file ".len..]}) catch "???";
|
|
|
357
|
return &[_][]const u8{ "bash", "-c", &cmd_buf };
|
|
|
358
|
}
|
|
|
359
|
};
|
|
|
360
|
|
|
345
|
361
|
const LogsRunner = struct {
|
|
346
|
362
|
fn init() Runner {
|
|
347
|
363
|
return Runner{ .name = "logs", .run_always = true, .toArgv = toArgv, .isActive = isActive };
|
|
|
@ -452,6 +468,7 @@ pub fn main() !void {
|
|
452
|
468
|
HelpRunner.init(),
|
|
453
|
469
|
ManPageRunner.init(),
|
|
454
|
470
|
SearchRunner.init(),
|
|
|
471
|
FileRunner.init(),
|
|
455
|
472
|
LogsRunner.init(),
|
|
456
|
473
|
QalcRunner.init(),
|
|
457
|
474
|
};
|