authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-31 18:55:51 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-31 18:55:51 -07:00
log088b0ec9662184edc155298e8f899a33dfb42a93
treec989e82a0977af79441401086f4a4d4816744b52
parentc3957c42b6ef932346f7d4fe11b5eeda25046e90

cmd/init- put cwd into a var


1 files changed, 3 insertions(+), 2 deletions(-)

src/cmd/init.zig+3-2
...@@ -19,6 +19,7 @@ pub fn execute(args: [][]u8) !void {...@@ -19,6 +19,7 @@ pub fn execute(args: [][]u8) !void {
1919
20 const stdout = std.io.getStdOut().writer();20 const stdout = std.io.getStdOut().writer();
21 const stdin = std.io.getStdIn().reader();21 const stdin = std.io.getStdIn().reader();
22 const cwd = std.fs.cwd();
2223
23 const id = try inquirer.answer(stdout, "ID (this gets autogenerated):", []const u8, "{s}", try u.random_string(48));24 const id = try inquirer.answer(stdout, "ID (this gets autogenerated):", []const u8, "{s}", try u.random_string(48));
2425
...@@ -37,7 +38,7 @@ pub fn execute(args: [][]u8) !void {...@@ -37,7 +38,7 @@ pub fn execute(args: [][]u8) !void {
37 else => return err,38 else => return err,
38 }) else null;39 }) else null;
3940
40 const license = try inquirer.forString(stdout, stdin, "license:", gpa, try detectlicense.detectInDir(gpa, std.fs.cwd()));41 const license = try inquirer.forString(stdout, stdin, "license:", gpa, try detectlicense.detectInDir(gpa, cwd));
4142
42 const description = try inquirer.forString(stdout, stdin, "description:", gpa, null);43 const description = try inquirer.forString(stdout, stdin, "description:", gpa, null);
4344
...@@ -56,7 +57,7 @@ pub fn execute(args: [][]u8) !void {...@@ -56,7 +57,7 @@ pub fn execute(args: [][]u8) !void {
56 std.debug.print("okay. quitting...", .{});57 std.debug.print("okay. quitting...", .{});
57 },58 },
58 true => {59 true => {
59 const file = try std.fs.cwd().createFile("zig.mod", .{});60 const file = try cwd.createFile("zig.mod", .{});
60 defer file.close();61 defer file.close();
61 const w = file.writer();62 const w = file.writer();
62 switch (ptype) {63 switch (ptype) {