comment cmd

This commit is contained in:
lucaspalomodevelop 2022-11-19 00:06:15 +01:00
parent 0a81571827
commit 1e6645d90a

View File

@ -5,6 +5,11 @@ let pagefile, tempfile;
let path = require("path");
let fs = require("fs");
/**
* this function filters the prefix and call the callback with the param
* @param {prefix, args } settings
* @param {*} callback
*/
let addCommand = ({prefix,args = myargs}, callback) =>
{
myargs.forEach((elem) =>{
@ -16,36 +21,61 @@ let addCommand = ({prefix,args = myargs}, callback) =>
})
}
/**
* -log | show jsste log
*/
addCommand({prefix:"-log"},(arg) =>{
jsste.setStateFunction((state) =>{
console.log(state);
})
})
/**
* -Jsconfig | set jsste config as json
*/
addCommand({prefix:"-Jsconfig="},(arg) =>{
jsste.__config.setConfig(arg);
})
/**
* -pageFile | set pageFile path
*/
addCommand({prefix:"-pageFile="},(arg) =>{
pagefile = JSON.parse(fs.readFileSync(arg, "utf8"));
pagefile["_SELFPATH_"] = path.dirname(arg);
})
/**
* -pageFile | set pageFile as json
*/
addCommand({prefix:"-page="},(arg) =>{
pagefile = JSON.parse(arg);
pagefile["_SELFPATH_"] = path.dirname(arg);
})
/**
* -tempFile | set tempFile path
*/
addCommand({prefix:"-tempFile="},(arg) =>{
tempfile = fs.readFileSync(arg, "utf8");
})
/**
* -pageFile | set pageFile as code
*/
addCommand({prefix:"-temp="},(arg) =>{
tempfile = arg
})
/**
* rendering
*/
output = jsste.render(pagefile || undefined, tempfile || undefined)
/**
* -info | show jsste.info
*/
addCommand({prefix:"-info"},(arg) =>{
if(arg == "?json")
@ -59,6 +89,9 @@ addCommand({prefix:"-info"},(arg) =>{
}
})
/**
* -out | write rendered code into the commandling
*/
addCommand({prefix:"-out"},(arg) =>{
console.log(output)
})