diff --git a/src/cli.ts b/src/cli.ts index 2a9e474..00ba854 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -7,6 +7,7 @@ import { scorecardsCommand } from "./commands/scorecards.js"; import { snapshotsCommand } from "./commands/snapshots.js"; import { studioCommand } from "./commands/studio.js"; import { teamsCommand } from "./commands/teams.js"; +import { workflowRunsCommand } from "./commands/workflowRuns.js"; import { workflowsCommand } from "./commands/workflows.js"; import { handleError } from "./commandHelpers.js"; @@ -54,6 +55,7 @@ function createProgram(): Command { program.addCommand(snapshotsCommand()); program.addCommand(studioCommand()); program.addCommand(teamsCommand()); + program.addCommand(workflowRunsCommand()); program.addCommand(workflowsCommand()); applyExitOverride(program); diff --git a/src/commands/teams.ts b/src/commands/teams.ts index 9846f32..07505d8 100644 --- a/src/commands/teams.ts +++ b/src/commands/teams.ts @@ -214,7 +214,7 @@ async function getTeamInfo( return response.body; } -async function listTeams(runtime: Runtime): Promise { +export async function listTeams(runtime: Runtime): Promise { const response = await request(runtime, "/teams.list", { method: "GET", }); diff --git a/src/commands/workflowRuns.ts b/src/commands/workflowRuns.ts new file mode 100644 index 0000000..b66273b --- /dev/null +++ b/src/commands/workflowRuns.ts @@ -0,0 +1,19 @@ +import { Command } from "commander"; + +import { addLinkCommand } from "./workflowRuns/addLink.js"; +import { changeStatusCommand } from "./workflowRuns/changeStatus.js"; +import { infoCommand } from "./workflowRuns/info.js"; +import { postMessageCommand } from "./workflowRuns/postMessage.js"; + +export function workflowRunsCommand(): Command { + const workflowRuns = new Command() + .name("workflowRuns") + .description("Trigger and monitor Self-service workflow runs"); + + workflowRuns.addCommand(addLinkCommand()); + workflowRuns.addCommand(changeStatusCommand()); + workflowRuns.addCommand(infoCommand()); + workflowRuns.addCommand(postMessageCommand()); + + return workflowRuns; +} diff --git a/src/commands/workflowRuns/addLink.ts b/src/commands/workflowRuns/addLink.ts new file mode 100644 index 0000000..d61838c --- /dev/null +++ b/src/commands/workflowRuns/addLink.ts @@ -0,0 +1,79 @@ +import { Command } from "commander"; + +import { + createExampleText, + getContext, + wrapAction, +} from "../../commandHelpers.js"; +import { buildRuntime } from "../../runtime.js"; +import { renderJson, renderRichText } from "../../renderers.js"; +import * as ui from "../../ui.js"; +import { request } from "../../http.js"; +import { Runtime } from "../../types.js"; + +export function addLinkCommand() { + return new Command() + .name("addLink") + .description("Add a link to a workflow run") + .argument("", "The ID of the workflow run") + .requiredOption("--url ", "The URL of the link") + .requiredOption("--label