UNPKG

xweb-templating

Version:

A cli tool for converting 'tags' to regular html, php or some other format

32 lines (29 loc) 1.03 kB
import { ArgumentsCamelCase } from "yargs"; import { read_config, save_config } from "../config/config.js"; import { error, warn } from "../log.js"; import { save_tagsets } from "./util.js"; export default async function run(argv: ArgumentsCamelCase<{ y: boolean; } & { names: string | undefined }>) { const CONFIG = read_config("add/config"); if (!CONFIG.use.tags) { error("add/config", "Cannot add tagset in a project that has disabled tagsets"); return; } if (argv.names == undefined) { error("add/config", "Cannot add tagsets without a name"); return; } const TAGSET_NAMES: string[] = argv.names?.split(" ") as string[]; for (const NAME of TAGSET_NAMES) { if (!CONFIG.tags.includes(NAME)) { CONFIG.tags.push(NAME); } else { await warn("add/config", `Tagset ${NAME} is already found in config file`, argv.y); } } save_config("add/config", CONFIG); save_tagsets("add/fetch", TAGSET_NAMES, CONFIG); }