aboutsummaryrefslogtreecommitdiff
path: root/deno/tools/manage-service.ts
blob: 148f55a568554c047503439fd9d3794af768acfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { join } from "@std/path";
// @ts-types="npm:@types/yargs"
import yargs from "yargs";

import { TemplateDir } from "./template.ts";

if (import.meta.main) {
  await yargs(Deno.args)
    .scriptName("manage-service")
    .option("project-dir", {
      type: "string",
    })
    .demandOption("project-dir")
    .command({
      command: "gen-tmpl",
      describe: "generate files for templates",
      builder: (builder) => {
        return builder
          .option("dry-run", {
            type: "boolean",
            default: true,
          })
          .strict();
      },
      handler: (argv) => {
        const { projectDir, dryRun } = argv;
        new TemplateDir(
          join(projectDir, "services/templates"),
        ).generateWithVariableFiles(
          [
            join(projectDir, "data/config"),
            join(projectDir, "services/config.template"),
          ],
          dryRun ? undefined : join(projectDir, "services/generated"),
        );
      },
    })
    .demandCommand(1, "One command must be specified.")
    .help()
    .strict()
    .parse();
}