Skip to content

Commit 6c0021b

Browse files
committed
cmd/init: ask if zigmod should write a test.zig
1 parent f01f9bf commit 6c0021b

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/cmd/init.zig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,26 @@ pub fn execute(self_name: []const u8, args: [][:0]u8) !void {
268268
}
269269
}
270270
}
271+
272+
// ask about test.zig
273+
if (!try extras.doesFileExist(null, "test.zig")) {
274+
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);
275+
if (do) {
276+
const file = try cwd.createFile("test.zig", .{});
277+
defer file.close();
278+
const w = file.writer();
279+
try w.print(
280+
\\const std = @import("std");
281+
\\const {s} = @import("{s}");
282+
\\
283+
,
284+
.{
285+
flatname,
286+
name,
287+
},
288+
);
289+
}
290+
}
271291
}
272292

273293
pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license: ?string, description: ?string) !void {

0 commit comments

Comments
 (0)