mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-08 08:04:25 +00:00
Add --silent & print result
This commit is contained in:
+14
-3
@@ -110,6 +110,7 @@ async function run(
|
||||
opts: GlobalOptions & {
|
||||
input: Record<string, any>;
|
||||
inputFrom: string | undefined;
|
||||
silent: boolean;
|
||||
},
|
||||
path: string
|
||||
) {
|
||||
@@ -135,8 +136,10 @@ async function run(
|
||||
const module = jobInfo.flow_status!.modules[i];
|
||||
|
||||
if (module.job) {
|
||||
console.log("====== Job " + (i + 1) + " ======");
|
||||
await track_job(workspace, module.job);
|
||||
if (!opts.silent) {
|
||||
console.log("====== Job " + (i + 1) + " ======");
|
||||
await track_job(workspace, module.job);
|
||||
}
|
||||
} else {
|
||||
console.log(module.type);
|
||||
await new Promise((resolve, _) =>
|
||||
@@ -147,7 +150,11 @@ async function run(
|
||||
i++;
|
||||
}
|
||||
|
||||
console.log(colors.green.underline.bold("Flow ran to completion"));
|
||||
if (!opts.silent) {
|
||||
console.log(colors.green.underline.bold("Flow ran to completion"));
|
||||
}
|
||||
const jobInfo = await JobService.getCompletedJob({ workspace, id });
|
||||
console.log(jobInfo.result ?? {});
|
||||
}
|
||||
|
||||
const command = new Command()
|
||||
@@ -167,6 +174,10 @@ const command = new Command()
|
||||
"--inputFrom <path:string>",
|
||||
"Read a JSON input object from a file. This will be merged with --input.* arguments."
|
||||
)
|
||||
.option(
|
||||
"-s --silent",
|
||||
"Do not ouput anything other then the final output. Useful for scripting."
|
||||
)
|
||||
.action(run as any);
|
||||
|
||||
export default command;
|
||||
|
||||
+22
-2
@@ -10,6 +10,7 @@ import {
|
||||
} from "https://deno.land/x/windmill@v1.50.0/windmill-api/index.ts";
|
||||
import { Table } from "https://deno.land/x/cliffy@v0.25.4/table/table.ts";
|
||||
import { green } from "https://deno.land/std@0.161.0/fmt/colors.ts";
|
||||
import { resolve } from "https://deno.land/std@0.141.0/path/win32.ts";
|
||||
|
||||
type ScriptFile = {
|
||||
parent_hash?: string;
|
||||
@@ -177,6 +178,7 @@ async function run(
|
||||
opts: GlobalOptions & {
|
||||
input: Record<string, any>;
|
||||
inputFrom: string | undefined;
|
||||
silent: boolean;
|
||||
},
|
||||
path: string
|
||||
) {
|
||||
@@ -186,13 +188,27 @@ async function run(
|
||||
? JSON.parse(await Deno.readTextFile(opts.inputFrom))
|
||||
: {};
|
||||
const input = { ...(opts.input ?? {}), ...inputFileContents };
|
||||
let id = await JobService.runScriptByPath({
|
||||
const id = await JobService.runScriptByPath({
|
||||
workspace,
|
||||
path,
|
||||
requestBody: input,
|
||||
});
|
||||
|
||||
track_job(workspace, id);
|
||||
if (!opts.silent) {
|
||||
await track_job(workspace, id);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
const result =
|
||||
(await JobService.getCompletedJob({ workspace, id })).result ?? {};
|
||||
console.log(result);
|
||||
|
||||
break;
|
||||
} catch {
|
||||
new Promise((resolve, _) => setTimeout(() => resolve(undefined), 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function track_job(workspace: string, id: string) {
|
||||
@@ -303,6 +319,10 @@ const command = new Command()
|
||||
"--inputFrom <path:string>",
|
||||
"Read a JSON input object from a file. This will be merged with --input.* arguments."
|
||||
)
|
||||
.option(
|
||||
"-s --silent",
|
||||
"Do not ouput anything other then the final output. Useful for scripting."
|
||||
)
|
||||
.action(run as any);
|
||||
|
||||
export default command;
|
||||
|
||||
Reference in New Issue
Block a user