1
0
silverbullet/cmd/plug_run.ts
Zef Hemel 30ba3fcca7
Refactoring work to support multi-tenancy and multiple storage, database backends (#598)
* Backend infrastructure
* New backend configuration work
* Factor out KV prefixing
* Don't put assets in the manifest cache
* Removed fancy authentication stuff
* Documentation updates
2023-12-10 13:23:42 +01:00

41 lines
897 B
TypeScript

import { runPlug } from "../cli/plug_run.ts";
import { path } from "../common/deps.ts";
import assets from "../dist/plug_asset_bundle.json" assert {
type: "json",
};
import { AssetBundle } from "../plugos/asset_bundle/bundle.ts";
export async function plugRunCommand(
{
hostname,
port,
}: {
hostname?: string;
port?: number;
},
spacePath: string,
functionName: string | undefined,
...args: string[]
) {
spacePath = path.resolve(spacePath);
console.log("Space path", spacePath);
console.log("Function to run:", functionName, "with arguments", args);
try {
const result = await runPlug(
spacePath,
functionName,
args,
new AssetBundle(assets),
port,
hostname,
);
if (result) {
console.log("Output", result);
}
Deno.exit(0);
} catch (e: any) {
console.error(e.message);
Deno.exit(1);
}
}