authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-01 01:24:28 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-01 01:24:28 -08:00
logf01f9bf9f529058d8907e89334f96340e12269f2
treee4fb75663e874b89a99afb0b485738a45f0b7d44
parent36bd8b373cad3217e0cc4dce2d1e3e4b3887947d

cmd/init: ask if zigmod should write the entry point


1 files changed, 34 insertions(+), 0 deletions(-)

src/cmd/init.zig+34
...@@ -234,6 +234,40 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void {...@@ -234,6 +234,40 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void {
234 }234 }
235 }235 }
236 }236 }
237
238 // ask about main.zig / mod.zig
239 if (!try extras.doesFileExist(null, entry orelse "main.zig")) {
240 const do = try inquirer.forConfirm(stdout, stdin, "It looks like your entry point doesn't exist. Do you want Zigmod to generate it for you?", gpa);
241 if (do) {
242 const file = try cwd.createFile(entry orelse "main.zig", .{});
243 defer file.close();
244 const w = file.writer();
245 switch (ptype) {
246 .exe => {
247 try w.print(
248 \\const std = @import("std");
249 \\const {s} = @import("{s}");
250 \\
251 \\pub fn main() void {{
252 \\ //
253 \\}}
254 \\
255 ,
256 .{
257 flatname,
258 name,
259 },
260 );
261 },
262 .lib => {
263 try w.writeAll(
264 \\const std = @import("std");
265 \\
266 );
267 },
268 }
269 }
270 }
237}271}
238272
239pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license: ?string, description: ?string) !void {273pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license: ?string, description: ?string) !void {