mirror of
https://github.com/lucaspalomodevelop/JSSTE.git
synced 2026-03-12 23:17:22 +00:00
comment cmd
This commit is contained in:
parent
0a81571827
commit
1e6645d90a
33
src/cmd.js
33
src/cmd.js
@ -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)
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user