UNPKG

codetainer

Version:

A clean and simple CLI to manage and store code snippets with ease.

27 lines (21 loc) 756 B
import chalk from "chalk"; import { loadSnippets, saveSnippets } from "../utils/snippetStore.js"; export function registerTagCommand(program) { program .command("tag <name> [tags...]") .description("Add tag(s) to a snippet") .action((name, tags) => { const snippets = loadSnippets(); if (!snippets[name]) { console.log(chalk.red(`❌ Snippet "${name}" not found.`)); return; } const existingTags = snippets[name].tags || []; const newTags = [...new Set([...existingTags, ...tags])]; snippets[name].tags = newTags; saveSnippets(snippets); console.log( chalk.green(`🏷️ Tags [${tags.join(", ")}] added to "${name}".`) ); }); }