UNPKG

@nesardramos/fmg

Version:

A CLI tool to manage path aliases in your terminal.

26 lines (24 loc) 735 B
// commands/set.js const { readAliases, writeAliases } = require("../utils/aliases"); const path = require("path"); exports.command = "set <alias> <targetPath>"; exports.aliases = ["s"]; exports.describe = "Set a new alias for a path."; exports.builder = (yargs) => { yargs .positional("alias", { describe: "The name of the alias.", type: "string", }) .positional("targetPath", { describe: "The target directory path.", type: "string", }); }; exports.handler = (argv) => { const aliases = readAliases(); const absolutePath = path.resolve(argv.targetPath); aliases[argv.alias] = absolutePath; writeAliases(aliases); console.log(`Alias '${argv.alias}' set to '${absolutePath}'.`); };