Skip to documentation
SLOP

tiny.smg.command.mutate.edge

Reference tiny.smg command mutate edge

Defined in command.mutate.

API (2)

Actions

Public operations.

No direct callersNo direct callscommand.mutateedge
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: tools/smg/src/command/mutate/edge.zig

zig
const std = @import("std");const smg = @import("../../root.zig");const graph_mod = smg.graph;const cli_metadata = smg.cli.metadata;const cli_options = smg.cli.options;const cli_output = smg.cli.output;const cli_resolve = smg.cli.resolve;const cli_session = smg.command.session;const cli_validation = smg.cli.validation;pub fn link(allocator: std.mem.Allocator, phases: std.mem.Allocator, args: []const []const u8, limits: smg.Limits) !u8 {    if (try cli_validation.rejectMissingOptionValues(allocator, args, &.{"--meta"})) return 2;    if (try cli_validation.rejectUnexpectedOptions(allocator, "link", "[OPTIONS] SOURCE REL TARGET", args, &.{"--meta"})) return 2;    const pos = try cli_options.positional(allocator, args);    if (pos.len == 0) {        try cli_output.writeClickUsageError(allocator, "link", "[OPTIONS] SOURCE REL TARGET", "Missing argument 'SOURCE'.");        return 2;    }    if (pos.len == 1) {        try cli_output.writeClickUsageError(allocator, "link", "[OPTIONS] SOURCE REL TARGET", "Missing argument 'REL'.");        return 2;    }    if (pos.len == 2) {        try cli_output.writeClickUsageError(allocator, "link", "[OPTIONS] SOURCE REL TARGET", "Missing argument 'TARGET'.");        return 2;    }    if (pos.len > 3) {        try cli_output.writeClickUsageError(allocator, "link", "[OPTIONS] SOURCE REL TARGET", try cli_validation.unexpectedArgumentMessage(allocator, pos[3..]));        return 2;    }    if (try cli_validation.rejectInvalidMeta(allocator, args)) return 2;    const loaded = try cli_session.loadMutation(allocator, phases, limits);    var graph = loaded.graph;    const source = try cli_resolve.graphNode(allocator, graph, pos[0], limits.suggestions);    const target = try cli_resolve.graphNode(allocator, graph, pos[2], limits.suggestions);    const meta = try cli_metadata.pairs(allocator, args, "manual");    try graph_mod.addEdge(&graph, .{ .source = source, .rel = try allocator.dupe(u8, pos[1]), .target = target, .metadata = meta });    try smg.storage.graph.publish(phases, loaded.root, graph, loaded.head, limits);    return try cli_output.writeOutFmt(allocator, "Linked {s} --{s}--> {s}\n", .{ source, pos[1], target });}pub fn unlink(allocator: std.mem.Allocator, phases: std.mem.Allocator, args: []const []const u8, limits: smg.Limits) !u8 {    if (try cli_validation.rejectUnexpectedOptions(allocator, "unlink", "[OPTIONS] SOURCE REL TARGET", args, &.{})) return 2;    const pos = try cli_options.positional(allocator, args);    if (pos.len == 0) {        try cli_output.writeClickUsageError(allocator, "unlink", "[OPTIONS] SOURCE REL TARGET", "Missing argument 'SOURCE'.");        return 2;    }    if (pos.len == 1) {        try cli_output.writeClickUsageError(allocator, "unlink", "[OPTIONS] SOURCE REL TARGET", "Missing argument 'REL'.");        return 2;    }    if (pos.len == 2) {        try cli_output.writeClickUsageError(allocator, "unlink", "[OPTIONS] SOURCE REL TARGET", "Missing argument 'TARGET'.");        return 2;    }    if (pos.len > 3) {        try cli_output.writeClickUsageError(allocator, "unlink", "[OPTIONS] SOURCE REL TARGET", try cli_validation.unexpectedArgumentMessage(allocator, pos[3..]));        return 2;    }    const loaded = try cli_session.loadMutation(allocator, phases, limits);    var graph = loaded.graph;    const source = try cli_resolve.graphNode(allocator, graph, pos[0], limits.suggestions);    const target = try cli_resolve.graphNode(allocator, graph, pos[2], limits.suggestions);    try graph_mod.removeEdge(&graph, source, pos[1], target);    try smg.storage.graph.publish(phases, loaded.root, graph, loaded.head, limits);    return try cli_output.writeOutFmt(allocator, "Unlinked {s} --{s}--> {s}\n", .{ source, pos[1], target });}

Source: tools/smg/src/command/mutate/root.zig:1

zig
pub const edge = @import("edge.zig");

Audit

Definitions3
Public names5
Members0
Version26.7.0
Revisiondaab053ee433