authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-02-10 20:52:07 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-02-10 20:52:07 -08:00
log14b8705a3ba28a8144db3a73021f7606fc9e1823
treecf29ee49ae21c5595ae4e38497397c27d5171496
parentc2f06cfbe3edc011b6978a4df2d17bbe808ee10a

remove cmd/add


2 files changed, 0 insertions(+), 56 deletions(-)

src/cmd_add.zig deleted-55
......@@ -1,55 +0,0 @@
1const std = @import("std");
2const gpa = std.heap.c_allocator;
3
4const u = @import("./util/index.zig");
5
6//
7//
8
9pub fn execute(args: [][]u8) !void {
10 //
11 u.assert(args.len >= 1, "missing package <type> parameter", .{});
12 u.assert(args.len >= 2, "missing package <path> parameter", .{});
13
14 const dept = args[0];
15 const path = args[1];
16
17 const dep_type = std.meta.stringToEnum(u.DepType, dept);
18 u.assert(dep_type != null, "provided <type> parameter \"{}\" is not a valid dependency type", .{dept});
19
20 const m = try u.ModFile.init(gpa, "zig.mod");
21 for (m.deps) |d| {
22 u.assert(!(d.type == dep_type.? and std.mem.eql(u8, d.path, path)), "dependency already added, skipping!", .{});
23 }
24
25 const ndl = &std.ArrayList(u.Dep).init(gpa);
26 for (m.deps) |d| {
27 try ndl.append(d);
28 }
29 try ndl.append(u.Dep{
30 .type = dep_type.?,
31 .path = path,
32 .name = "",
33 .main = "",
34 .version = "",
35 .c_include_dirs = &[_][]const u8{},
36 .c_source_flags = &[_][]const u8{},
37 .c_source_files = &[_][]const u8{},
38 });
39
40 //
41 const f = try std.fs.cwd().createFile("zig.mod", .{});
42 defer f.close();
43
44 const w = f.writer();
45 try w.print("name: {}\n", .{m.name});
46 try w.print("main: {}\n", .{m.main});
47 try w.print("dependencies:\n", .{});
48
49 for (ndl.items) |d| {
50 try w.print("- type: {}\n", .{@tagName(d.type)});
51 try w.print(" path: {}\n", .{d.path});
52 }
53
54 u.print("Successfully added {s}", .{path});
55}
src/main.zig-1
......@@ -8,7 +8,6 @@ const u = @import("./util/index.zig");
88
99pub const commands = struct {
1010 const init = @import("./cmd_init.zig");
11 // const add = @import("./cmd_add.zig");
1211 const fetch = @import("./cmd_fetch.zig");
1312 const sum = @import("./cmd_sum.zig");
1413 const zpm = @import("./cmd_zpm.zig");