diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-06-09 22:02:33 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-06-10 15:25:12 +0800 |
commit | 133bbc64f891afc1ae6c965176cddbc9050f9e80 (patch) | |
tree | d4411565d41e214df0aefd79bfe9240ab8f0fb0f /deno/service-manager/main.ts | |
parent | cc013584714e8ce1f583ce391f8123881e3c0297 (diff) | |
download | crupest-133bbc64f891afc1ae6c965176cddbc9050f9e80.tar.gz crupest-133bbc64f891afc1ae6c965176cddbc9050f9e80.tar.bz2 crupest-133bbc64f891afc1ae6c965176cddbc9050f9e80.zip |
refactor(deno): done template generation.
Diffstat (limited to 'deno/service-manager/main.ts')
-rw-r--r-- | deno/service-manager/main.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/deno/service-manager/main.ts b/deno/service-manager/main.ts new file mode 100644 index 0000000..93f4c1b --- /dev/null +++ b/deno/service-manager/main.ts @@ -0,0 +1,39 @@ +import { parseArgs } from "@std/cli"; +import { loadVariables, 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."); + } +} |