From 14b8705a3ba28a8144db3a73021f7606fc9e1823 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 10 Feb 2021 20:52:07 -0800 Subject: [PATCH] remove cmd/add --- src/cmd_add.zig | 55 ------------------------------------------------- src/main.zig | 1 - 2 files changed, 56 deletions(-) delete mode 100644 src/cmd_add.zig diff --git a/src/cmd_add.zig b/src/cmd_add.zig deleted file mode 100644 index bc342f8ed4cae0d4745f9ed7e78442c552707172..0000000000000000000000000000000000000000 --- a/src/cmd_add.zig +++ /dev/null @@ -1,55 +0,0 @@ -const std = @import("std"); -const gpa = std.heap.c_allocator; - -const u = @import("./util/index.zig"); - -// -// - -pub fn execute(args: [][]u8) !void { - // - u.assert(args.len >= 1, "missing package parameter", .{}); - u.assert(args.len >= 2, "missing package parameter", .{}); - - const dept = args[0]; - const path = args[1]; - - const dep_type = std.meta.stringToEnum(u.DepType, dept); - u.assert(dep_type != null, "provided parameter \"{}\" is not a valid dependency type", .{dept}); - - const m = try u.ModFile.init(gpa, "zig.mod"); - for (m.deps) |d| { - u.assert(!(d.type == dep_type.? and std.mem.eql(u8, d.path, path)), "dependency already added, skipping!", .{}); - } - - const ndl = &std.ArrayList(u.Dep).init(gpa); - for (m.deps) |d| { - try ndl.append(d); - } - try ndl.append(u.Dep{ - .type = dep_type.?, - .path = path, - .name = "", - .main = "", - .version = "", - .c_include_dirs = &[_][]const u8{}, - .c_source_flags = &[_][]const u8{}, - .c_source_files = &[_][]const u8{}, - }); - - // - const f = try std.fs.cwd().createFile("zig.mod", .{}); - defer f.close(); - - const w = f.writer(); - try w.print("name: {}\n", .{m.name}); - try w.print("main: {}\n", .{m.main}); - try w.print("dependencies:\n", .{}); - - for (ndl.items) |d| { - try w.print("- type: {}\n", .{@tagName(d.type)}); - try w.print(" path: {}\n", .{d.path}); - } - - u.print("Successfully added {s}", .{path}); -} diff --git a/src/main.zig b/src/main.zig index e19d15d0cf21c5d7874cdbb72568078cb0e1bfc7..2b354ba8911d83a6a007d9727998e9b031b49c65 100644 --- a/src/main.zig +++ b/src/main.zig @@ -8,7 +8,6 @@ const u = @import("./util/index.zig"); pub const commands = struct { const init = @import("./cmd_init.zig"); - // const add = @import("./cmd_add.zig"); const fetch = @import("./cmd_fetch.zig"); const sum = @import("./cmd_sum.zig"); const zpm = @import("./cmd_zpm.zig"); -- 2.54.0