Skip to documentation
SLOP

tiny.smg.cli.resolve

Reference tiny.smg cli resolve

Defined in cli.

API (2)

Actions

Public operations.

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

Source

Called byCallscommand.nodeshowprivate; no linktools.smg.src.cli.resolvewriteAmbiguousprivate; no linktools.smg.src.cli.resolvewriteNotFoundviewlookupviewsuggestNodescli.resolvegraphNode
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallscommand.usagesrunprivate; no linktools.smg.src.cli.resolvewriteAmbiguousprivate; no linktools.smg.src.cli.resolvewriteNotFoundstorage.contextresolveNodeNameFromReadercli.resolvestoredNode
Static calls · unresolved targets: 0 · external targets: 0.

Source: tools/smg/src/cli/resolve.zig

zig
const std = @import("std");const smg = @import("../root.zig");const graph_mod = smg.graph;const output = smg.cli.output;const storage = smg.storage;const view = smg.view;pub fn graphNode(allocator: std.mem.Allocator, graph: graph_mod.Graph, raw: []const u8, limits: smg.SuggestionLimits) ![]const u8 {    const matches = try view.lookup(graph, allocator, raw, limits);    if (matches.len == 1) return matches[0];    if (matches.len == 0) {        try writeNotFound(allocator, raw, try view.suggestNodes(graph, allocator, raw, limits.displayed_name_count, limits));        return error.NodeNotFound;    }    try writeAmbiguous(allocator, raw, matches);    return error.AmbiguousName;}pub fn storedNode(    allocator: std.mem.Allocator,    root: []const u8,    reader: *storage.database.Reader,    raw: []const u8,    limits: smg.SuggestionLimits,) ![]const u8 {    return switch (try storage.context.resolveNodeNameFromReader(        allocator,        root,        reader,        raw,        limits,    )) {        .resolved => |name| name,        .missing => |suggestions| {            try writeNotFound(allocator, raw, suggestions);            return error.NodeNotFound;        },        .ambiguous => |matches| {            try writeAmbiguous(allocator, raw, matches);            return error.AmbiguousName;        },    };}fn writeNotFound(allocator: std.mem.Allocator, raw: []const u8, suggestions: []const []const u8) !void {    var out: std.Io.Writer.Allocating = .init(allocator);    defer out.deinit();    try out.writer.print("Error: node not found: {s}\n", .{raw});    if (suggestions.len != 0) {        try out.writer.writeAll("Did you mean:\n");        for (suggestions) |name| try out.writer.print("  {s}\n", .{name});    }    try output.writeErr(out.written());}fn writeAmbiguous(allocator: std.mem.Allocator, raw: []const u8, matches: []const []const u8) !void {    var out: std.Io.Writer.Allocating = .init(allocator);    defer out.deinit();    try out.writer.print("Error: ambiguous name {s}, matches:\n", .{raw});    for (matches) |match| try out.writer.print("  {s}\n", .{match});    try output.writeErr(out.written());}

Source: tools/smg/src/cli/root.zig:8

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

Audit

Definitions3
Public names3
Members0
Version26.7.0
Revisiondaab053ee433