import {help} from "./help"; import {init} from "./init"; import {version} from "./version"; import {Server} from "../server"; import {Make} from "./make"; export function commandHandler({command, params}): void { const commands: Object = { 'version': () => version(), 'init': () => init(), 'help': () => help(), 'serve': () => new Server().start(), 'watch': () => new Server().watch(), 'make:page': () => Make.page(params), 'make:pattern': () => Make.item('pattern', params), 'make:component': () => Make.item('component', params), }; if (command in commands) { try { commands[command](params); } catch (error) { throw new Error(error); } } else { throw new Error(`Command: ${command} not recognized.`); } }