From a65f01fdd0c17a30d35a25826da48661c10889c2 Mon Sep 17 00:00:00 2001 From: Ankit Patial Date: Sat, 17 Jan 2026 18:38:48 +0530 Subject: [PATCH] Remove main.zig CLI executable Library-only project - examples are in src/examples/ --- build.zig | 41 ---------------------------------- src/main.zig | 62 ---------------------------------------------------- 2 files changed, 103 deletions(-) delete mode 100644 src/main.zig diff --git a/build.zig b/build.zig index 465c1d2..e4e1137 100644 --- a/build.zig +++ b/build.zig @@ -8,37 +8,7 @@ pub fn build(b: *std.Build) void { .target = target, }); - const exe = b.addExecutable(.{ - .name = "pugz", - .root_module = b.createModule(.{ - .root_source_file = b.path("src/main.zig"), - .target = target, - .optimize = optimize, - .imports = &.{ - .{ .name = "pugz", .module = mod }, - }, - }), - }); - - b.installArtifact(exe); - const run_step = b.step("run", "Run the app"); - - const run_cmd = b.addRunArtifact(exe); - run_step.dependOn(&run_cmd.step); - - // By making the run step depend on the default step, it will be run from the - // installation directory rather than directly from within the cache directory. - run_cmd.step.dependOn(b.getInstallStep()); - - // This allows the user to pass arguments to the application in the build - // command itself, like this: `zig build run -- arg1 arg2 etc` - if (b.args) |args| { - run_cmd.addArgs(args); - } - // Creates an executable that will run `test` blocks from the provided module. - // Here `mod` needs to define a target, which is why earlier we made sure to - // set the releative field. const mod_tests = b.addTest(.{ .root_module = mod, }); @@ -46,16 +16,6 @@ pub fn build(b: *std.Build) void { // A run step that will run the test executable. const run_mod_tests = b.addRunArtifact(mod_tests); - // Creates an executable that will run `test` blocks from the executable's - // root module. Note that test executables only test one module at a time, - // hence why we have to create two separate ones. - const exe_tests = b.addTest(.{ - .root_module = exe.root_module, - }); - - // A run step that will run the second test executable. - const run_exe_tests = b.addRunArtifact(exe_tests); - // Integration tests - general template tests const general_tests = b.addTest(.{ .root_module = b.createModule(.{ @@ -100,7 +60,6 @@ pub fn build(b: *std.Build) void { // make the two of them run in parallel. const test_step = b.step("test", "Run all tests"); test_step.dependOn(&run_mod_tests.step); - test_step.dependOn(&run_exe_tests.step); test_step.dependOn(&run_general_tests.step); test_step.dependOn(&run_doctype_tests.step); test_step.dependOn(&run_inheritance_tests.step); diff --git a/src/main.zig b/src/main.zig deleted file mode 100644 index 73faa22..0000000 --- a/src/main.zig +++ /dev/null @@ -1,62 +0,0 @@ -const std = @import("std"); -const pugz = @import("pugz"); - -pub fn main() !void { - var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init; - defer _ = gpa.deinit(); - - // Use arena allocator - recommended for templates (all memory freed at once) - var arena = std.heap.ArenaAllocator.init(gpa.allocator()); - defer arena.deinit(); - const allocator = arena.allocator(); - - std.debug.print("=== Pugz Template Engine ===\n\n", .{}); - - // Simple API: renderTemplate - one function call does everything - std.debug.print("--- Simple API (recommended for servers) ---\n", .{}); - const html = try pugz.renderTemplate(allocator, - \\doctype html - \\html - \\ head - \\ title= title - \\ body - \\ h1 Hello, #{name}! - \\ p Welcome to Pugz. - \\ ul - \\ each item in items - \\ li= item - , .{ - .title = "My Page", - .name = "World", - .items = &[_][]const u8{ "First", "Second", "Third" }, - }); - std.debug.print("{s}\n", .{html}); - - // Advanced API: parse once, render multiple times with different data - std.debug.print("--- Advanced API (parse once, render many) ---\n", .{}); - - const source = - \\p Hello, #{name}! - ; - - // Tokenize & Parse (do this once) - var lexer = pugz.Lexer.init(allocator, source); - const tokens = try lexer.tokenize(); - var parser = pugz.Parser.init(allocator, tokens); - const doc = try parser.parse(); - - // Render multiple times with different data - const html1 = try pugz.render(allocator, doc, .{ .name = "Alice" }); - const html2 = try pugz.render(allocator, doc, .{ .name = "Bob" }); - - std.debug.print("Render 1: {s}", .{html1}); - std.debug.print("Render 2: {s}", .{html2}); -} - -test "simple test" { - const gpa = std.testing.allocator; - var list: std.ArrayListUnmanaged(i32) = .empty; - defer list.deinit(gpa); - try list.append(gpa, 42); - try std.testing.expectEqual(@as(i32, 42), list.pop()); -}