UNPKG

@bemedev/cli-test

Version:

A library for testing CLI libraries (INCEPTION !!)

40 lines (37 loc) 1.13 kB
import { command, flag, boolean } from 'cmd-ts'; import { INITIALIZATION_SUCCESS, INITIALIZATION_FAILED, REMOVING_SUCCESS, REMOVING_FAILED } from '../constants.js'; import { writeConfig, removeConfig } from './cli.utils.js'; const cli = command({ name: 'cli-test', description: `Generate a setup file for cli testing`, version: '0.0.1', args: { init: flag({ description: 'init', short: 'i', type: boolean, long: 'init', }), remove: flag({ description: 'remove', short: 'r', type: boolean, long: 'remove', }), }, handler: async ({ init, remove }) => { const l = console.log; if (init) { return writeConfig() .then(() => l(INITIALIZATION_SUCCESS)) .catch(() => l(INITIALIZATION_FAILED)); } if (remove) { return removeConfig() .then(() => l(REMOVING_SUCCESS)) .catch(() => l(REMOVING_FAILED)); } }, }); export { cli }; //# sourceMappingURL=cli.js.map