| ... | @@ -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 | } |
| 238 | | 272 | |
| 239 | pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license: ?string, description: ?string) !void { | 273 | pub fn writeExeManifest(w: std.fs.File.Writer, id: string, name: string, license: ?string, description: ?string) !void { |