aboutsummaryrefslogtreecommitdiff
path: root/deno/tools/manage-service.ts
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-06-13 13:55:05 +0800
committerYuqian Yang <crupest@crupest.life>2025-06-13 13:56:35 +0800
commit0c174baec106266462eede0bb82b1ada19db0908 (patch)
tree644d80cb0094b169740a922147b3a952d0eef66e /deno/tools/manage-service.ts
parent226a8b060d4da35771fe455554b212d38efb20fd (diff)
downloadcrupest-0c174baec106266462eede0bb82b1ada19db0908.tar.gz
crupest-0c174baec106266462eede0bb82b1ada19db0908.tar.bz2
crupest-0c174baec106266462eede0bb82b1ada19db0908.zip
deno: move service manager to tools.
Diffstat (limited to 'deno/tools/manage-service.ts')
-rw-r--r--deno/tools/manage-service.ts39
1 files changed, 39 insertions, 0 deletions
diff --git a/deno/tools/manage-service.ts b/deno/tools/manage-service.ts
new file mode 100644
index 0000000..45e09ec
--- /dev/null
+++ b/deno/tools/manage-service.ts
@@ -0,0 +1,39 @@
+import { parseArgs } from "@std/cli";
+import { TemplateDir } from "./template.ts";
+import { join } from "@std/path";
+
+if (import.meta.main) {
+ const args = parseArgs(Deno.args, {
+ string: ["project-dir"],
+ boolean: ["no-dry-run"],
+ });
+
+ if (args._.length === 0) {
+ throw new Error("You must specify a command.");
+ }
+
+ const projectDir = args["project-dir"];
+ if (projectDir == null) {
+ throw new Error("You must specify project-dir.");
+ }
+
+ const command = String(args._[0]);
+
+ switch (command) {
+ case "gen-tmpl":
+ new TemplateDir(
+ join(projectDir, "services/templates"),
+ ).generateWithVariableFiles(
+ [
+ join(projectDir, "data/config"),
+ join(projectDir, "services/config.template"),
+ ],
+ args["no-dry-run"] === true
+ ? join(projectDir, "services/generated")
+ : undefined,
+ );
+ break;
+ default:
+ throw new Error(command + " is not a valid command.");
+ }
+}