| author | |
| committer | |
| log | ca3781fe4e4ff41e642ef48a21095734ca6fd585 |
| tree | cc1b5f415dcd442005877121ee669cb7ca33d973 |
| parent | d312857810eefe270ea5edb8f5517ce74c839d54 |
5 files changed, 113 insertions(+), 15 deletions(-)
deps.zig+31-1| ... | @@ -53,6 +53,11 @@ const dirs = struct { | ... | @@ -53,6 +53,11 @@ const dirs = struct { |
| 53 | pub const _u9w9dpp6p804 = cache ++ "/git/github.com/MasterQ32/zig-uri"; | 53 | pub const _u9w9dpp6p804 = cache ++ "/git/github.com/MasterQ32/zig-uri"; |
| 54 | pub const _ocmr9rtohgcc = cache ++ "/git/github.com/nektro/zig-json"; | 54 | pub const _ocmr9rtohgcc = cache ++ "/git/github.com/nektro/zig-json"; |
| 55 | pub const _tnj3qf44tpeq = cache ++ "/git/github.com/nektro/zig-range"; | 55 | pub const _tnj3qf44tpeq = cache ++ "/git/github.com/nektro/zig-range"; |
| 56 | pub const _2ovav391ivak = cache ++ "/git/github.com/nektro/zig-detect-license"; | ||
| 57 | pub const _pt88y5d80m25 = cache ++ "/git/github.com/nektro/zig-licenses-text"; | ||
| 58 | pub const _96h80ezrvj7i = cache ++ "/git/github.com/nektro/zig-leven"; | ||
| 59 | pub const _qyrnfg0iwpzl = cache ++ "/git/github.com/nektro/zig-fs-check"; | ||
| 60 | pub const _c1xirp1ota5p = cache ++ "/git/github.com/nektro/zig-inquirer"; | ||
| 56 | pub const _o6ogpor87xc2 = cache ++ "/git/github.com/marlersoft/zigwin32"; | 61 | pub const _o6ogpor87xc2 = cache ++ "/git/github.com/marlersoft/zigwin32"; |
| 57 | }; | 62 | }; |
| 58 | 63 | ||
| ... | @@ -114,9 +119,34 @@ pub const package_data = struct { | ... | @@ -114,9 +119,34 @@ pub const package_data = struct { |
| 114 | .pkg = Pkg{ .name = "range", .path = .{ .path = dirs._tnj3qf44tpeq ++ "/src/lib.zig" }, .dependencies = null }, | 119 | .pkg = Pkg{ .name = "range", .path = .{ .path = dirs._tnj3qf44tpeq ++ "/src/lib.zig" }, .dependencies = null }, |
| 115 | }; | 120 | }; |
| 116 | 121 | ||
| 122 | pub const _pt88y5d80m25 = Package{ | ||
| 123 | .directory = dirs._pt88y5d80m25, | ||
| 124 | .pkg = Pkg{ .name = "licenses-text", .path = .{ .path = dirs._pt88y5d80m25 ++ "/src/lib.zig" }, .dependencies = null }, | ||
| 125 | }; | ||
| 126 | |||
| 127 | pub const _96h80ezrvj7i = Package{ | ||
| 128 | .directory = dirs._96h80ezrvj7i, | ||
| 129 | .pkg = Pkg{ .name = "leven", .path = .{ .path = dirs._96h80ezrvj7i ++ "/src/lib.zig" }, .dependencies = &.{_tnj3qf44tpeq.pkg.?} }, | ||
| 130 | }; | ||
| 131 | |||
| 132 | pub const _qyrnfg0iwpzl = Package{ | ||
| 133 | .directory = dirs._qyrnfg0iwpzl, | ||
| 134 | .pkg = Pkg{ .name = "fs-check", .path = .{ .path = dirs._qyrnfg0iwpzl ++ "/src/lib.zig" }, .dependencies = null }, | ||
| 135 | }; | ||
| 136 | |||
| 137 | pub const _2ovav391ivak = Package{ | ||
| 138 | .directory = dirs._2ovav391ivak, | ||
| 139 | .pkg = Pkg{ .name = "detect-license", .path = .{ .path = dirs._2ovav391ivak ++ "/src/lib.zig" }, .dependencies = &.{ _pt88y5d80m25.pkg.?, _96h80ezrvj7i.pkg.?, _qyrnfg0iwpzl.pkg.? } }, | ||
| 140 | }; | ||
| 141 | |||
| 142 | pub const _c1xirp1ota5p = Package{ | ||
| 143 | .directory = dirs._c1xirp1ota5p, | ||
| 144 | .pkg = Pkg{ .name = "inquirer", .path = .{ .path = dirs._c1xirp1ota5p ++ "/src/lib.zig" }, .dependencies = &.{ _s84v9o48ucb0.pkg.?, _tnj3qf44tpeq.pkg.? } }, | ||
| 145 | }; | ||
| 146 | |||
| 117 | pub const _89ujp8gq842x = Package{ | 147 | pub const _89ujp8gq842x = Package{ |
| 118 | .directory = dirs._89ujp8gq842x, | 148 | .directory = dirs._89ujp8gq842x, |
| 119 | .pkg = Pkg{ .name = "zigmod", .path = .{ .path = dirs._89ujp8gq842x ++ "/src/lib.zig" }, .dependencies = &.{ _s84v9o48ucb0.pkg.?, _2ta738wrqbaq.pkg.?, _0npcrzfdlrvk.pkg.?, _ejw82j2ipa0e.pkg.?, _ocmr9rtohgcc.pkg.?, _tnj3qf44tpeq.pkg.? } }, | 149 | .pkg = Pkg{ .name = "zigmod", .path = .{ .path = dirs._89ujp8gq842x ++ "/src/lib.zig" }, .dependencies = &.{ _s84v9o48ucb0.pkg.?, _2ta738wrqbaq.pkg.?, _0npcrzfdlrvk.pkg.?, _ejw82j2ipa0e.pkg.?, _ocmr9rtohgcc.pkg.?, _tnj3qf44tpeq.pkg.?, _2ovav391ivak.pkg.?, _qyrnfg0iwpzl.pkg.?, _c1xirp1ota5p.pkg.? } }, |
| 120 | }; | 150 | }; |
| 121 | 151 | ||
| 122 | pub const _o6ogpor87xc2 = Package{ | 152 | pub const _o6ogpor87xc2 = Package{ |
src/cmd/init.zig+67-12| ... | @@ -1,35 +1,90 @@ | ... | @@ -1,35 +1,90 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const gpa = std.heap.c_allocator; | 2 | const gpa = std.heap.c_allocator; |
| 3 | 3 | ||
| 4 | const inquirer = @import("inquirer"); | ||
| 5 | const detectlicense = @import("detect-license"); | ||
| 4 | const u = @import("./../util/index.zig"); | 6 | const u = @import("./../util/index.zig"); |
| 5 | 7 | ||
| 6 | // | 8 | // |
| 7 | // | 9 | // |
| 8 | 10 | ||
| 9 | pub fn execute(args: [][]u8) !void { | 11 | pub fn execute(args: [][]u8) !void { |
| 10 | const name = u.detect_pkgname(u.try_index([]const u8, args, 0, ""), "") catch |err| switch (err) { | 12 | _ = args; |
| 13 | |||
| 14 | std.debug.print("This utility will walk you through creating a zig.mod file.\n", .{}); | ||
| 15 | std.debug.print("That will give a good launching off point to get your next project started.\n", .{}); | ||
| 16 | std.debug.print("Use `zigmod aq add <pkg>` to add a dependency from https://aquila.red/\n", .{}); | ||
| 17 | std.debug.print("Press ^C at any time to quit.\n", .{}); | ||
| 18 | std.debug.print("\n", .{}); | ||
| 19 | |||
| 20 | const stdout = std.io.getStdOut().writer(); | ||
| 21 | const stdin = std.io.getStdIn().reader(); | ||
| 22 | |||
| 23 | const id = try inquirer.answer(stdout, "ID (this gets autogenerated):", []const u8, "{s}", try u.random_string(48)); | ||
| 24 | |||
| 25 | const ptype = try inquirer.forEnum(stdout, stdin, "Are you making an application or a library?", gpa, enum { exe, lib }, null); | ||
| 26 | |||
| 27 | const name = try inquirer.forString(stdout, stdin, "package name:", gpa, u.detect_pkgname(u.try_index([]const u8, args, 0, ""), "") catch |err| switch (err) { | ||
| 11 | error.NoBuildZig => { | 28 | error.NoBuildZig => { |
| 12 | u.assert(false, "init requires a build.zig file", .{}); | 29 | u.assert(false, "init requires a build.zig file", .{}); |
| 13 | unreachable; | 30 | unreachable; |
| 14 | }, | 31 | }, |
| 15 | else => return err, | 32 | else => return err, |
| 16 | }; | 33 | }); |
| 17 | const mainf = u.detct_mainfile(u.try_index([]const u8, args, 1, ""), null, name) catch |err| switch (err) { | 34 | |
| 35 | const entry = if (ptype == .lib) try inquirer.forString(stdout, stdin, "package entry point:", gpa, u.detct_mainfile(u.try_index([]const u8, args, 1, ""), null, name) catch |err| switch (err) { | ||
| 18 | error.CantFindMain => { | 36 | error.CantFindMain => { |
| 19 | u.assert(false, "unable to detect package entry point", .{}); | 37 | u.assert(false, "unable to detect package entry point", .{}); |
| 20 | unreachable; | 38 | unreachable; |
| 21 | }, | 39 | }, |
| 22 | else => return err, | 40 | else => return err, |
| 23 | }; | 41 | }) else null; |
| 42 | |||
| 43 | const license = try inquirer.forString(stdout, stdin, "license:", gpa, try detectlicense.detectInDir(gpa, std.fs.cwd())); | ||
| 24 | 44 | ||
| 25 | const file = try std.fs.cwd().createFile("zig.mod", .{}); | 45 | const description = try inquirer.forString(stdout, stdin, "description:", gpa, null); |
| 26 | defer file.close(); | ||
| 27 | 46 | ||
| 28 | const fwriter = file.writer(); | 47 | std.debug.print("\n", .{}); |
| 29 | try fwriter.print("id: {s}\n", .{u.random_string(48)}); | 48 | std.debug.print("About to write local zig.mod:\n", .{}); |
| 30 | try fwriter.print("name: {s}\n", .{name}); | 49 | |
| 31 | try fwriter.print("main: {s}\n", .{mainf}); | 50 | std.debug.print("\n", .{}); |
| 32 | try fwriter.print("dependencies:\n", .{}); | 51 | switch (ptype) { |
| 52 | .exe => try writeExeManifest(stdout, id, name, license, description), | ||
| 53 | .lib => try writeLibManifest(stdout, id, name, entry.?, license, description), | ||
| 54 | } | ||
| 55 | |||
| 56 | std.debug.print("\n", .{}); | ||
| 57 | switch (try inquirer.forConfirm(stdout, stdin, "Is this okay?", gpa)) { | ||
| 58 | false => { | ||
| 59 | std.debug.print("okay. quitting...", .{}); | ||
| 60 | }, | ||
| 61 | true => { | ||
| 62 | const file = try std.fs.cwd().createFile("zig.mod", .{}); | ||
| 63 | defer file.close(); | ||
| 64 | const w = file.writer(); | ||
| 65 | switch (ptype) { | ||
| 66 | .exe => try writeExeManifest(w, id, name, license, description), | ||
| 67 | .lib => try writeLibManifest(w, id, name, entry.?, license, description), | ||
| 68 | } | ||
| 69 | std.debug.print("\n", .{}); | ||
| 70 | u.print("Successfully initialized new package {s}!\n", .{name}); | ||
| 71 | }, | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | fn writeExeManifest(w: std.fs.File.Writer, id: []const u8, name: []const u8, license: []const u8, description: []const u8) !void { | ||
| 76 | try w.print("id: {s}\n", .{id}); | ||
| 77 | try w.print("name: {s}\n", .{name}); | ||
| 78 | try w.print("license: {s}\n", .{license}); | ||
| 79 | try w.print("description: {s}\n", .{description}); | ||
| 80 | try w.print("dev_dependencies:\n", .{}); | ||
| 81 | } | ||
| 33 | 82 | ||
| 34 | u.print("Initialized a new package named {s} with entry point {s}", .{ name, mainf }); | 83 | fn writeLibManifest(w: std.fs.File.Writer, id: []const u8, name: []const u8, entry: []const u8, license: []const u8, description: []const u8) !void { |
| 84 | try w.print("id: {s}\n", .{id}); | ||
| 85 | try w.print("name: {s}\n", .{name}); | ||
| 86 | try w.print("main: {s}\n", .{entry}); | ||
| 87 | try w.print("license: {s}\n", .{license}); | ||
| 88 | try w.print("description: {s}\n", .{description}); | ||
| 89 | try w.print("dependencies:\n", .{}); | ||
| 35 | } | 90 | } |
zig.mod+3| ... | @@ -35,6 +35,9 @@ dependencies: | ... | @@ -35,6 +35,9 @@ dependencies: |
| 35 | - src: git https://github.com/truemedian/zfetch | 35 | - src: git https://github.com/truemedian/zfetch |
| 36 | - src: git https://github.com/nektro/zig-json | 36 | - src: git https://github.com/nektro/zig-json |
| 37 | - src: git https://github.com/nektro/zig-range | 37 | - src: git https://github.com/nektro/zig-range |
| 38 | - src: git https://github.com/nektro/zig-detect-license | ||
| 39 | - src: git https://github.com/nektro/zig-fs-check | ||
| 40 | - src: git https://github.com/nektro/zig-inquirer | ||
| 38 | 41 | ||
| 39 | dev_dependencies: | 42 | dev_dependencies: |
| 40 | - src: git https://github.com/marlersoft/zigwin32 | 43 | - src: git https://github.com/marlersoft/zigwin32 |
zigmod.lock+6-1| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | 2 | 1 | 2 |
| 2 | git https://github.com/yaml/libyaml tag-0.2.5 | 2 | git https://github.com/yaml/libyaml tag-0.2.5 |
| 3 | git https://github.com/nektro/zig-ansi commit-8ffadb65efdb424c6fe07a804107a775d55ebfe5 | 3 | git https://github.com/nektro/zig-ansi commit-d4a53bcac5b87abecc65491109ec22aaf5f3dc2f |
| 4 | git https://github.com/ziglibs/known-folders commit-f5e5fb8370de41fbc220c0c0770d62bdf00530ea | 4 | git https://github.com/ziglibs/known-folders commit-f5e5fb8370de41fbc220c0c0770d62bdf00530ea |
| 5 | git https://github.com/nektro/zig-licenses commit-c9b8cbf3565675a056ad4e9b57cb4f84020e7680 | 5 | git https://github.com/nektro/zig-licenses commit-c9b8cbf3565675a056ad4e9b57cb4f84020e7680 |
| 6 | git https://github.com/truemedian/zfetch commit-8bbc7b34cd417794841e1432585334bc969dfe83 | 6 | git https://github.com/truemedian/zfetch commit-8bbc7b34cd417794841e1432585334bc969dfe83 |
| ... | @@ -10,4 +10,9 @@ git https://github.com/MasterQ32/zig-network commit-b9c91769d8ebd626c8e45b2abb05 | ... | @@ -10,4 +10,9 @@ git https://github.com/MasterQ32/zig-network commit-b9c91769d8ebd626c8e45b2abb05 |
| 10 | git https://github.com/MasterQ32/zig-uri commit-52cdd2061bec0579519f0d30280597f3a1db8b75 | 10 | git https://github.com/MasterQ32/zig-uri commit-52cdd2061bec0579519f0d30280597f3a1db8b75 |
| 11 | git https://github.com/nektro/zig-json commit-72e555fbc0776f2600aee19b01e5ab1855ebec7a | 11 | git https://github.com/nektro/zig-json commit-72e555fbc0776f2600aee19b01e5ab1855ebec7a |
| 12 | git https://github.com/nektro/zig-range commit-890ca308fe09b3d5c866d5cfb3b3d7a95dbf939f | 12 | git https://github.com/nektro/zig-range commit-890ca308fe09b3d5c866d5cfb3b3d7a95dbf939f |
| 13 | git https://github.com/nektro/zig-detect-license commit-0ebd7d7c80b88fd5b606ee2ec57e9c6e23927fbf | ||
| 14 | git https://github.com/nektro/zig-licenses-text commit-3c07c6e4eb0965dafd0b029c632f823631b3169c | ||
| 15 | git https://github.com/nektro/zig-leven commit-8e9f827117ab1418578b692a2325754cc3ee692d | ||
| 16 | git https://github.com/nektro/zig-fs-check commit-dcd8da90fcb8bf3c9887e713bf0ec072bc897dd5 | ||
| 17 | git https://github.com/nektro/zig-inquirer commit-d36621903868136b2ce347e9be9c937e664e1e74 | ||
| 13 | git https://github.com/marlersoft/zigwin32 commit-ca6b8e5c378e31655fa11b886b44b62f703ef090 | 18 | git https://github.com/marlersoft/zigwin32 commit-ca6b8e5c378e31655fa11b886b44b62f703ef090 |
zigmod.sum+6-1| ... | @@ -1,5 +1,5 @@ | ... | @@ -1,5 +1,5 @@ |
| 1 | blake3-22472b867734926b202c055892fb0abb03f91556cd88998e2fe77addb003b1dd v/git/github.com/yaml/libyaml/tag-0.2.5 | 1 | blake3-22472b867734926b202c055892fb0abb03f91556cd88998e2fe77addb003b1dd v/git/github.com/yaml/libyaml/tag-0.2.5 |
| 2 | blake3-f4e0cc5432c5d4532d7f69f935c0517b5e315934cdaff40e514b5375546f5756 git/github.com/nektro/zig-ansi | 2 | blake3-3c76436cde156ef2b92eca8e2a38cc2e07f23055422cfe903585bab8bcc47dd9 git/github.com/nektro/zig-ansi |
| 3 | blake3-35a1c330c9999876e71418a7d43ad24ca7d1e23c3b5576e5cb75667e3392cc10 git/github.com/ziglibs/known-folders | 3 | blake3-35a1c330c9999876e71418a7d43ad24ca7d1e23c3b5576e5cb75667e3392cc10 git/github.com/ziglibs/known-folders |
| 4 | blake3-42c3fae77ef41d2074e74de2d91cfc66bc591170494b10262dd2aeaea0b60cb5 git/github.com/nektro/zig-licenses | 4 | blake3-42c3fae77ef41d2074e74de2d91cfc66bc591170494b10262dd2aeaea0b60cb5 git/github.com/nektro/zig-licenses |
| 5 | blake3-e3072f7fb47e86d53c9a1879e254ba1af55941153fd5f6752ec659b2f14854c9 git/github.com/truemedian/zfetch | 5 | blake3-e3072f7fb47e86d53c9a1879e254ba1af55941153fd5f6752ec659b2f14854c9 git/github.com/truemedian/zfetch |
| ... | @@ -9,4 +9,9 @@ blake3-21f91e48333ac0ca7f4704c96352831c25216e7056d02ce24de95d03fc942246 git/gith | ... | @@ -9,4 +9,9 @@ blake3-21f91e48333ac0ca7f4704c96352831c25216e7056d02ce24de95d03fc942246 git/gith |
| 9 | blake3-030ebb03f1ed21122e681b06786bea6f2f1b810e8eb9f2029d0eee4f4fb3103f git/github.com/MasterQ32/zig-uri | 9 | blake3-030ebb03f1ed21122e681b06786bea6f2f1b810e8eb9f2029d0eee4f4fb3103f git/github.com/MasterQ32/zig-uri |
| 10 | blake3-1893709ffc6359c5f9cd2f9409abccf78a94ed37bb2c6dd075c603356d17c94b git/github.com/nektro/zig-json | 10 | blake3-1893709ffc6359c5f9cd2f9409abccf78a94ed37bb2c6dd075c603356d17c94b git/github.com/nektro/zig-json |
| 11 | blake3-09698753782139ab4877d08f33235170836f68b73e482b65cdee5637a6addf86 git/github.com/nektro/zig-range | 11 | blake3-09698753782139ab4877d08f33235170836f68b73e482b65cdee5637a6addf86 git/github.com/nektro/zig-range |
| 12 | blake3-e9e11cd5724286e0365ebdd5c17f35bcf75a4c1f6deb0060fc2e142ea0aa47bd git/github.com/nektro/zig-detect-license | ||
| 13 | blake3-20ceb9e27bdb93540e93006628fb94e0540f3f69a2304a8f73ad2989b8e27226 git/github.com/nektro/zig-licenses-text | ||
| 14 | blake3-cf68eaad66254b89c8bc18578f58607aa2e87ae59dd5696c2394eb5a0a31c455 git/github.com/nektro/zig-leven | ||
| 15 | blake3-10460da714f5c8436d09c268795597b0b2686ffc1e789c9f50366c2cbb0e1ff3 git/github.com/nektro/zig-fs-check | ||
| 16 | blake3-1cfc14f309d2dc8994bd8e2fc4e029cfee139ea2aef130a139bd996de3a538a8 git/github.com/nektro/zig-inquirer | ||
| 12 | blake3-949c3cd2c9e834190feeecb010c59ab5047fa721cfbdf67e0f0fd847194a6dad git/github.com/marlersoft/zigwin32 | 17 | blake3-949c3cd2c9e834190feeecb010c59ab5047fa721cfbdf67e0f0fd847194a6dad git/github.com/marlersoft/zigwin32 |