diff options
Diffstat (limited to '')
| -rw-r--r-- | src/main.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig index b99f28c..60e40fe 100644 --- a/src/main.zig +++ b/src/main.zig @@ -87,6 +87,10 @@ const Cli = struct { }, .handler = &Cli.gen, }, + .{ + .name = "serve", + .handler = &Cli.serve, + }, }, .handler = struct { fn inner(_: Io, _: Allocator, _: std.BufSet, _: [][]const u8) anyerror!void { @@ -109,6 +113,9 @@ const Cli = struct { \\ gen ROOT-DIR TARGET-DIR \\ runs build for relevant files \\ + \\ serve ROOT-DIR + \\ serves the site (using caddy) + \\ \\ , .{}); } @@ -249,6 +256,19 @@ const Cli = struct { try root_dir.access(io, "preproc.lua", .{}); // check preproc script try shell(io, pandoc_command, .{ .cwd = .{ .dir = root_dir } }); } + + fn serve(io: Io, _: Allocator, _: FlagSet, args: [][]const u8) !void { + if (args.len != 1) return Cli.usage(); + + const root_path = args[0]; + const root_dir = try Io.Dir.cwd().openDir(io, root_path, .{}); + defer root_dir.close(io); + + log.info("srv : root={s}", .{root_path}); + try shell(io, + \\caddy fmt --overwrite && caddy run --watch + , .{ .cwd = .{ .dir = root_dir } }); + } }; const File = struct { |