---
source: lib/src/sdk/typescript/types.rs
expression: client
---
// @generated by usage-cli from test.usage.kdl. Do not edit manually.
import { CliRunner, CliResult } from "./runtime";
import { ToolFlags } from "./types";

export class Tool {
  private runner: CliRunner;

  constructor(binPath?: string) {
    this.runner = new CliRunner(binPath ?? "tool");
  }
  /** [-f --format <fmt>] */
  async exec(flags?: ToolFlags): Promise<CliResult> {
    const cmdArgs: string[] = [];
    const flagArgs = this.buildFlagArgs(flags);
    return this.runner.run([...cmdArgs, ...flagArgs]);
  }

  private buildFlagArgs(flags?: ToolFlags): string[] {
    const result: string[] = [];
    if (!flags) return result;
    if (flags.format !== undefined) { result.push("--format", String(flags.format)); }
    return result;
  }
}
