From 6c0021b9315cc1450ca37f2f56493b6b4548a413 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 1 Jan 2026 01:24:48 -0800 Subject: [PATCH] cmd/init: ask if zigmod should write a test.zig --- src/cmd/init.zig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/cmd/init.zig b/src/cmd/init.zig index 59c31699cea50cb2feaec29e98f86f0ccf1ed759..3737db3b423dd2f425cec3d37ae721160689f53a 100644 --- a/src/cmd/init.zig +++ b/src/cmd/init.zig @@ -268,6 +268,26 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void { } } } + + // ask about test.zig + if (!try extras.doesFileExist(null, "test.zig")) { + const do = try inquirer.forConfirm(stdout, stdin, "It looks like there's no test.zig. Do you want Zigmod to generate it for you?", gpa); + if (do) { + const file = try cwd.createFile("test.zig", .{}); + defer file.close(); + const w = file.writer(); + try w.print( + \\const std = @import("std"); + \\const {s} = @import("{s}"); + \\ + , + .{ + flatname, + name, + }, + ); + } + } } pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license: ?string, description: ?string) !void { -- 2.54.0