function buildCommand
buildCommand(
command: string,
options?: { attributes?: Record<string, string | number | boolean>; queries?: Record<string, string | number | boolean>; }
): string[]

Builds a command sentence from structured data

Examples

Build a simple command

import { assertEquals } from "@std/assert";
import { buildCommand } from "@hertzg/routeros-api/protocol/command";

const words = buildCommand("/interface/print");
assertEquals(words, ["/interface/print"]);

Build command with attributes

import { assertEquals } from "@std/assert";
import { buildCommand } from "@hertzg/routeros-api/protocol/command";

const words = buildCommand("/interface/set", {
  attributes: { "name": "ether1-new", "disabled": "yes" }
});
assertEquals(words, ["/interface/set", "=name=ether1-new", "=disabled=yes"]);

Build command with queries

import { assertEquals } from "@std/assert";
import { buildCommand } from "@hertzg/routeros-api/protocol/command";

const words = buildCommand("/interface/print", {
  queries: { "name": "ether1" }
});
assertEquals(words, ["/interface/print", "?name=ether1"]);

Parameters

command: string

Command path (e.g., "/interface/print")

optional
options: { attributes?: Record<string, string | number | boolean>; queries?: Record<string, string | number | boolean>; }

Optional attributes and query parameters

Return Type

string[]

Array of words ready to be encoded