runEdit

tcmts.cli.run.runEdit · #zjqmmjyo · term · runs on the server

uses tcmts.cli.main.execute, which uses tcmts.cli.help.usageError, which uses tcmts.cli.help.usageOf, which uses tcmts.cli.style.bold, which uses node:util

Runs tcm edit.

import { routeEdit } from "#codebase/tcmts/cli/commands";
import { edit, execute } from "#codebase/tcmts/cli/main";
import type { Context } from "#codebase/tcmts/cli/run";
import { chooseName } from "#codebase/tcmts/cli/ui";
import { parse } from "@bomb.sh/router";

export async function runEdit({ cb, cmd, rest, scratch }: Context): Promise<number> {
  const { model } = execute(cmd, parse(routeEdit(), { argv: rest }));
  const names = model.names.length
    ? model.names
    : [await chooseName(cb, "edit <name>...", "Edit which definition?")];
  edit(
    cb,
    names,
    model.file !== undefined
      ? scratch(model.file)
      : (jsx) => scratch(undefined, jsx ? "scratch.tsx" : "scratch.ts"),
    model.force,
  );
  return 0;
}

uses

used by