UNPKG

fot

Version:

A simple tool that lets you start a project without the hassle of creating the same folders over and over again. Create once... and never again.

2 lines 2.02 kB
#!/usr/bin/env node var args=process.argv.slice(2),shell=require("shelljs"),fs=require("fs"),setPath=require("./commands/setPath"),cloneDir=require("./commands/cloneDir"),getPath=require("./commands/getPath"),clearPath=require("./commands/clearPath"),listTemps=require("./commands/listTemps"),helpString="Commands: \n- 'fot here': Set the templates directory to the working directory.\n- 'fot get': Get the template directory's absolute path.\n- 'fot set {abs-path}': Set the templates directory to the absolute path {abs-path}\n- 'fot clone {template} {OPTIONAL new filename}': Clone a template into the working directory.\n- 'fot clear': Forget your templates dir.\n- 'fot list': Lists all the templates in your templates dir.\n\nWith great node packages come ridiculous bugs so please do report them :D",command=args[0],input=args[1],extra=args[2];try{switch(command){case"set":if(!input||!isString(input))throw'ERROR: Incorrect option usage! Correct: "fot set {templates path(string)}"';console.log(setPath(input));break;case"here":if(input)throw'ERROR: Incorrect option usage! Correct: "fot here"';console.log(setPath(process.cwd()));break;case"get":if(input)throw'ERROR: Incorrect option usage! Correct: "fot get"';var path=getPath(),output=path||"Nothing";console.log("INFO: The templates directory is set to - "+output);break;case"clone":if(!input||!isString(input))throw'ERROR: Incorrect option usage! Correct: "fot clone {template name(string)} {folder name upon creation(string)}"';console.log(cloneDir(input,process.cwd(),extra||null));break;case"clear":if(input||extra)throw'ERROR: Incorrect option usage! Correct: "fot clear"';console.log(clearPath());break;case"list":if(input||extra)throw'ERROR: Incorrect option usage! Correct: "fot list"';var files=listTemps();console.log("SUCCESS: Here are all the templates you got:");for(var i=0;i<files.length;++i)console.log(files[i]);break;default:console.log(helpString)}}catch(e){console.error(e)}function isString(e){return"string"==typeof e||e instanceof String}