diff --git a/buildos.js b/buildos.js index 7bae3a6a..6b9ca1af 100644 --- a/buildos.js +++ b/buildos.js @@ -398,7 +398,7 @@ try { "xml": OPENAF_BUILD_HOME + "/src/openaf/plugins/XML.java", //"xls": OPENAF_BUILD_HOME + "/src/openaf/plugins/XLS.java", //"svn": OPENAF_BUILD_HOME + "/src/openaf/plugins/SVN.java", - "git": OPENAF_BUILD_HOME + "/src/openaf/plugins/GIT.java", + //"git": OPENAF_BUILD_HOME + "/src/openaf/plugins/GIT.java", //"smb": OPENAF_BUILD_HOME + "/src/openaf/plugins/SMB.java", "zip": OPENAF_BUILD_HOME + "/src/openaf/plugins/ZIP.java", //"ignite": OPENAF_BUILD_HOME + "/src/openaf/plugins/Ignite.java", diff --git a/js/openaf.js b/js/openaf.js index 37a745bb..0c45f8b9 100644 --- a/js/openaf.js +++ b/js/openaf.js @@ -3365,6 +3365,9 @@ const plugin = function(aPlugin, aClass) { if (String(e).indexOf("java.lang.ClassNotFoundException: DOC") >= 0) { throw("The DOC plugin is no longer included. Please install the XLS oPack (\"opack install plugin-xls\")."); } + if (String(e).indexOf("java.lang.ClassNotFoundException: GIT") >= 0) { + throw("The GIT plugin is no longer included. Please install the GIT oPack (\"opack install plugin-git\")."); + } } } diff --git a/lib/org.eclipse.jgit-5.13.2.jar b/lib/org.eclipse.jgit-5.13.2.jar deleted file mode 100644 index 92e3a8e1..00000000 Binary files a/lib/org.eclipse.jgit-5.13.2.jar and /dev/null differ diff --git a/ojob.json b/ojob.json index fe73be97..0bab3cc2 100755 --- a/ojob.json +++ b/ojob.json @@ -1 +1 @@ -{"jobs":[{"name":"ojob pass","typeArgs":{"noLog":true,"shortcut":{"name":"pass","keyArg":"__args","args":{"debug":"__debug","templateArgs":"__templateArgs"}}},"help":{"text":"Placeholder/pass job to allow for arguments injection","expects":[{"name":"__args","desc":"The args to inject"},{"name":"__debug","desc":"Boolean to indicate that args to be inject should be printed before"},{"name":"__templateArgs","desc":"Boolean, true by default, to indicate to apply template to each string in args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"}]},"check":{"in":{"__args":"isMap.default({})","__debug":"toBoolean.isBoolean.default(false)","__templateArgs":"toBoolean.isBoolean.default(true)"}},"exec":"var b=clone(args.__args);args.__templateArgs?traverse(b,function(c,a,e,d){isNull(a)&&(d[c]=__);isString(a)&&0<=a.indexOf(\"{{\")&&(d[c]=templify(a,args))}):traverse(b,function(c,a,e,d){isNull(a)&&(d[c]=__)});args.__debug&&cprint(ow.format.withSideLine(printTreeOrS(b,__,{bgcolor:\"BG(235)\"}),__,\"FG(240)\",\"BG(235)\",ow.format.withSideLineThemes().openBottomCurvedRect));delete args.__argsp;delete args.__debug;delete args.__templateArgs;args=merge(args,b)"},{"name":"ojob debug","typeArgs":{"noLog":true,"shortcut":{"name":"jobdebug","keyArg":"job","args":{"lineColor":"lineColor","textColor":"textColor","theme":"theme","emoticons":"emoticons","signs":"signs","includeTime":"includeTime"}}},"help":{"text":"Outputs the current args and res values to help debug an ojob flow."},"exec":"ow.loadFormat();print(\"\");cprint(ow.format.withSideLine(\"ARGS:\",__,\"FG(240)\",\"BG(240),BOLD\",ow.format.withSideLineThemes().openBottomCurvedRect));cprint(ow.format.withSideLine(colorify(args,{bgcolor:\"BG(235)\"}),__,\"FG(240)\",\"BG(235)\",ow.format.withSideLineThemes().openTopCurvedRect));cprint(ow.format.withSideLine(\"RES:\",__,\"FG(240),BOLD\",\"BG(240),BOLD\",ow.format.withSideLineThemes().openBottomCurvedRect));cprint(ow.format.withSideLine(colorify($get(\"res\"),{bgcolor:\"BG(235)\"}),__,\"FG(240)\",\n\"BG(235)\",ow.format.withSideLineThemes().openTopCurvedRect))"},{"name":"ojob job debug","typeArgs":{"noLog":true,"shortcut":{"name":"jobsdebug","keyArg":"jobs","args":{"lineColor":"lineColor","textColor":"textColor","theme":"theme","emoticons":"emoticons","signs":"signs","includeTime":"includeTime"}}},"help":{"text":"Provides an alternative to print based debug.\n\nExample:\n # ----------------\n - name: Sample job\n exec: |\n //@ Declaring array\n var ar = [ 0, 1, 2, 3, 4, 5 ]\n\n //@ Start cycle\n var ii = 0;\n while(ii < ar.length) {\n print(\"II = \" + ii)\n ii++\n //# ii == 3\n }\n //@ End cycle\n //? ii\n\n //?s args\n //?y args\n","expects":[{"name":"job","desc":"The job to change to include debug"},{"name":"jobs","desc":"The jobs array to change to include debug"},{"name":"lineColor","desc":"The line color around the debug info"},{"name":"textColor","desc":"The text color around the debug info"},{"name":"theme","desc":"The withSideLineThemes theme to use"},{"name":"emoticons","desc":"If emoticons should be used or not"},{"name":"signs","desc":"A custom map of emoticons (keys: checkpoint, assert and print)"},{"name":"includeTime","desc":"A boolean value to indicate if a time indication should be included"}]},"check":{"in":{"job":"isString.default(__)","jobs":"isArray.default([])","lineColor":"isString.default(\"FG(220)\")","textColor":"isString.default(\"BG(230),BLACK\")","lineError":"isString.default(\"FG(220)\")","textError":"isString.default(\"BG(196),FG(255),BOLD\")","theme":"isString.default(\"doubleLineBothSides\")","emoticons":"toBoolean.isBoolean.default(true)","signs":"isMap.default(__)","includeTime":"toBoolean.isBoolean.default(false)"}},"exec":"isMap(void 0)&&(args=merge(void 0,args));args.signs=_$(args.signs,\"signs\").isMap().default({checkpoint:127866,assert:128077,print:128270,error:128545,time:\"\\ud83d\\udd52\"});isDef(args.job)&&0==args.jobs.length&&args.jobs.push(args.job);if(isUnDef(getEnv(\"OJOB_DEBUG\"))||toBoolean(getEnv(\"OJOB_DEBUG\"))){ow.loadFormat();var h=ow.oJob.getJobsCh();0==args.jobs.length&&(args.jobs=h.getKeys().filter(function(e){return\"ojob job debug\"!=e.name}).map(function(e){return e.name}));var k=!1;isDef(ow.loadDebug)&&\n(ow.loadDebug(),ow.debug.register(),k=!0);args.jobs.forEach(function(e){var d=h.get({name:e});if(k){if(isUnDef(d.lang)||isDef(d.lang)&&(\"oaf\"==d.lang||\"js\"==d.lang))d.exec=ow.debug.debug(d.exec,args,!0)}else{var f=function(c,a){var g=\";try{\";isDef(a)&&(g+=\"if(\"+a+\") {\");var l=args.includeTime?'(new Date()).toISOString() +\" | \" + ':\"\";g+=\"cprint(ow.format.withSideLine(\"+l+c+', __, \"'+args.lineColor+'\", \"'+args.textColor+'\", ow.format.withSideLineThemes().'+args.theme+\")) \";isDef(a)&&(g+=\"}\");return g+=\n\"}catch(__e_debug){cprint(ow.format.withSideLine(\"+l+\"' \"+b.error+\" ' + String(__e_debug), __, \\\"\"+args.lineError+'\", \"'+args.textError+'\", ow.format.withSideLineThemes().'+args.theme+\"))};\"};if(args.emoticons){var b=args.signs;isNumber(b.checkpoint)&&(b.checkpoint=ow.format.string.unicode(b.checkpoint));isNumber(b.assert)&&(b.assert=ow.format.string.unicode(b.assert));isNumber(b.print)&&(b.print=ow.format.string.unicode(b.print));isNumber(b.error)&&(b.error=ow.format.string.unicode(b.error))}b.checkpoint=\n_$(b.checkpoint).default(\"@\");b.assert=_$(b.assert).default(\"#\");b.print=_$(b.print).default(\"?\");b.error=_$(b.error).default(\"!\");d.exec=d.exec.split(\"\\n\").map(function(c){var a=c.trim().match(/\\/\\/@ (.+)$/);isArray(a)&&(a=a[1],c=c.replace(/\\/\\/@ (.+)$/,f('\" '+b.checkpoint+\" \"+a.replace(/\"/g,'\\\\\"')+'\"')));a=c.trim().match(/\\/\\/# (.+)$/);isArray(a)&&(a=a[1],c=c.replace(/\\/\\/# (.+)$/,f('\" '+b.assert+\" \"+a+'\"',a)));a=c.trim().match(/\\/\\/\\? (.+)$/);isArray(a)&&(a=a[1],c=c.replace(/\\/\\/\\? (.+)$/,f('\" '+\nb.print+\" \"+a+' = \" + stringify('+a+') + \"\"')));a=c.trim().match(/\\/\\/\\?s (.+)$/);isArray(a)&&(a=a[1],c=c.replace(/\\/\\/\\?s (.+)$/,f('\" '+b.print+\" \"+a+' = \" + af.toSLON('+a+') + \"\"')));a=c.trim().match(/\\/\\/\\?y (.+)$/);isArray(a)&&(a=a[1],c=c.replace(/\\/\\/\\?y (.+)$/,f('\" '+b.print+\" \"+a+' = \" + af.toYAML('+a+') + \"\"')));return c}).join(\"\\n\")}h.set({name:e},d)})}"},{"name":"ojob get pm","args":{"__key":"args"},"check":{"in":{"__key":"isString.default(\"res\")"}},"exec":"var a=__pm;isDef(__pm._map)&&(a=__pm._map);isDef(__pm._list)&&(a=__pm._list);\"args\"==args.__key?args=merge(args,a):$set(args.__key,a);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob get","typeArgs":{"shortcut":{"name":"get","keyArg":"__key","args":{"path":"__path"}}},"help":{"text":"Retrieves a specific map key (or path) using $get","expects":[{"name":"__key","desc":"Map key to retrieve (key is also checked for compatibility)"},{"name":"__path","desc":"The path to consider from the __key"}]},"check":{"in":{"__key":"isString.default(\"res\")","__path":"isString.default(\"@\")"}},"exec":"isUnDef(args.__key)&&isDef(args.key)&&(args.__key=args.key);var a=\"args\"==args.__key?$path(args,args.__path):$path($get(args.__key),args.__path);isArray(a)&&(a={_list:a});args=merge(args,a);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob set","typeArgs":{"shortcut":{"name":"set","keyArg":"__key","args":{"path":"__path"}}},"help":{"text":"Sets a \"key\" with the current value on a \"path\" using $set","expects":[{"name":"__key","desc":"Map key"},{"name":"__path","desc":"A key or path to a value from the current args"}]},"check":{"in":{"__key":"isString.default(\"res\")","__path":"isString"}},"exec":"var b=$path(args,args.__path);isDef(b)&&\"args\"!=args.__key&&$set(args.__key,b);Object.keys(args).filter(function(a){return a.startsWith(\"__\")}).forEach(function(a){return delete args[a]})"},{"name":"ojob unset","typeArgs":{"shortcut":{"name":"unset","keyArg":"__key"}},"help":{"text":"Unsets a \"key\" using $unset","expects":[{"name":"__key","desc":"Map key"}],"check":{"in":{"__key":"isString.default(\"res\")"}}},"exec":"$unset(args.__key);Object.keys(args).filter(function(a){return a.startsWith(\"__\")}).forEach(function(a){return delete args[a]})"},{"name":"ojob file get","typeArgs":{"noLog":true,"shortcut":{"name":"fileget","keyArg":"__file","args":{"path":"__path","cache":"__cache","ttl":"__ttl","out":"__out","key":"__key"}}},"help":{"text":"Retrieves a specific map key (or path) from an YAML or JSON file provided.","expects":[{"name":"__file","desc":"The file path to an YAML or JSON file","required":true},{"name":"__path","desc":"Path of the file contents"},{"name":"__cache","desc":"Boolean value that if false it won't cache the file contents (default: true)"},{"name":"__ttl","desc":"If cache is enabled lets you define a numeric ttl"},{"name":"__out","desc":"The path on args to set the map key/path contents"},{"name":"__key","desc":"If __out is not defined will set the content into the provided key"}]},"check":{"in":{"__file":"isString","__path":"isString.default(\"@\")","__cache":"toBoolean.isBoolean.default(true)","__ttl":"isNumber.default(__)","__out":"isString.default(__)","__key":"isString.default(\"res\")"}},"exec":"if(args.__cache){var c=$cache(\"__ojob_file_get\");isDef(args.__ttl)&&(c=c.ttl(args.__ttl));c=c.fn(function(a){return isDef(a.file)?a.file.endsWith(\".json\")?io.readFileJSON(a.file):/\\.ya?ml$/.test(a.file)?io.readFileYAML(a.file):{error:\"Not an yaml, yml or json file.\"}:{}}).create();var b=c.get({file:args.__file})}else b=args.__file.endsWith(\".json\")?io.readFileJSON(args.__file):/\\.ya?ml$/.test(args.__file)?io.readFileYAML(args.__file):{error:\"Not an yaml, yml or json file.\"};b=$path(b,\nargs.__path);isDef(args.__out)?$$(args).set(args.__out,b):isDef(args.__key)?$set(args.__key,b):Object.keys(b).forEach(function(a){return $$(args).set(a,b[a])});Object.keys(args).filter(function(a){return a.startsWith(\"__\")}).forEach(function(a){return delete args[a]})"},{"name":"ojob template","typeArgs":{"shortcut":{"name":"template","keyArg":"template","args":{"templateFile":"templateFile","data":"data","dataFile":"dataFile","outputFile":"outputFile","key":"__key","tpath":"__tpath","dpath":"__dpath","outPath":"__outPath","out":"__out"}}},"help":{"text":"Applies the OpenAF template over the provided data producing an output.","expects":[{"name":"__key","desc":"The key that holds template and/or data (default to 'res'). If 'args' it will use the current arguments."},{"name":"__tpath","desc":"The path in __key where a string with the template can be found."},{"name":"__dpath","desc":"The path in __key where a map/array data to use can be found."},{"name":"__out","desc":"The output will be stored into the provided key (defaults to 'res')"},{"name":"__outPath","desc":"If defined the $set path where __out will be set in the provided key."},{"name":"template","desc":"If defined, will be used as template"},{"name":"templateFile","desc":"If defined, it will use the provided template file."},{"name":"data","desc":"If defined, will be used as data"},{"name":"dataFile","desc":"If defined, it will use the provided data file (either yaml or json)."},{"name":"outputFile","desc":"If defined, the output will be written to the provided file path."}],"returns":[{"name":"output","desc":"If no outputFile is provided this will hold the output of applying the template with the provided data"}]},"check":{"in":{"__key":"isString.default(\"res\")","__tpath":"isString.default(\"@\")","__dpath":"isString.default(\"@\")","__out":"isString.default(\"res\")","__outPath":"isString.default(\"\")","templateFile":"isString.default(__)","dataFile":"isString.default(__)","outputFile":"isString.default(__)"}},"exec":"ow.loadTemplate();ow.template.addConditionalHelpers();ow.template.addFormatHelpers();ow.template.addOpenAFHelpers();var a=isDef(args.data)?args.data:\"args\"==args.__key?$path(args,args.__dpath):$path($get(args.__key),args.__dpath);isDef(args.dataFile)&&(a=args.dataFile.match(/\\.ya?ml$/i)?io.readFileYAML(args.dataFile):io.readFileJSON(args.dataFile));var b=isDef(args.template)?args.template:\"args\"==args.__key?$path(args,args.__tpath):$path($get(args.__key),args.__tpath);isDef(args.templateFile)&&\n(b=io.readFileString(args.templateFile));isDef(args.logJob)&&$job(args.logJob,args);a=templify(b,a);isDef(args.outputFile)?io.writeFileString(args.outputFile,a):\"args\"==args.__out?isDef(args.__outPath)?$$(args).set(args.__outPath,a):args.output=a:(b={},isDef(args.__outPath)&&$$(b).set(args.__outPath,a),b.output=a,$set(args.__out,b))"},{"name":"ojob template folder","typeArgs":{"shortcut":{"name":"templateFolder","keyArg":"templateFolder","args":{"templatePath":"__templatePath","data":"data","dataFile":"dataFile","outputFolder":"outputFolder","key":"__key","dpath":"__dpath","logJob":"logJob","metaTemplate":"metaTemplate"}}},"help":{"text":"Given a templateFolder it will execute 'ojob template' for each (recursively), with the provided data, to output to outputFolder. Optionally metaTemplate can be use where each json/yaml file in templateFolder all or part of the arguments for 'ojob template'.\n","expects":[{"name":"templateFolder","desc":"The original folder where the templates are located.","required":true},{"name":"__templatePath","desc":"If defined, will apply a $path string over the recursive list of files in templateFolder."},{"name":"outputFolder","desc":"The path where the output should be stored.","required":true},{"name":"data","desc":"If defined, will be used as data"},{"name":"dataFile","desc":"If defined, it will use the provided data file (either yaml or json)."},{"name":"__key","desc":"The key that holds template and/or data (default to 'res'). If 'args' it will use the current arguments."},{"name":"__dpath","desc":"The path in __key where a map/array data to use can be found."},{"name":"logJob","desc":"A ojob job to log the 'ojob template' activity (receives the same arguments as 'ojob template')"},{"name":"metaTemplate","desc":"Boolean that if 'true' will interpret any json/yaml file, in the templateFolder, as a map/array of arguments to use when calling 'ojob template' overriden the defaults."}]},"check":{"in":{"templateFolder":"isString","__templatePath":"isString.default(\"@\")","outputFolder":"isString","dataFile":"isString.default(__)","__key":"isString.default(\"res\")","__dpath":"isString.default(\"@\")","logJob":"isString.default(__)","metaTemplate":"toBoolean.isBoolean.default(false)"}},"exec":"var e=isDef(args.data)?args.data:\"args\"==args.__key?$path(args,args.__dpath):$path($get(args.__key),args.__dpath);isDef(args.dataFile)&&(e=args.dataFile.match(/\\.ya?ml$/i)?io.readFileYAML(args.dataFile):io.readFileJSON(args.dataFile));var b=[];$path(listFilesRecursive(args.templateFolder),args.__templatePath).forEach(function(a){var d={templateFile:a.filepath,outputFile:a.filepath.replace(new RegExp(\"^\"+args.templateFolder),args.outputFolder),data:e,logJob:args.logJob};args.metaTemplate&&\na.filename.match(/\\.(ya?ml|json)$/i)?(a=a.filename.match(/\\.ya?ml$/i)?io.readFileYAML(a.filepath):io.readFileJSON(a.filepath),delete d.templateFile,isMap(a)&&(isDef(a.outputFile)&&!a.outputFile.startsWith(\"/\")&&(a.outputFile=args.outputFolder+\"/\"+a.outputFile),b.push(merge(d,a))),isArray(a)&&(b=b.concat(a.map(function(c){isDef(c.outputFile)&&!c.outputFile.startsWith(\"/\")&&(c.outputFile=args.outputFolder+\"/\"+c.outputFile);return merge(d,c)})))):b.push(d)});io.mkdir(args.outputFolder);$job(\"ojob template\",\nb)"},{"name":"ojob find/replace","typeArgs":{"noLog":true,"shortcut":{"name":"findReplace","keyArg":"__key","args":{"path":"__path","inputKey":"inputKey","inputPath":"inputPath","inputFile":"inputFile","outputFile":"outputFile","useRegExp":"useRegExp","flagsRegExp":"flagsRegExp","logJob":"logJob"}}},"help":{"text":"Performs an in-memory find/replace on a provided string or file and outputs to args.output or, optionally, to a file.","expects":[{"name":"__key","desc":"The key that holds template and/or data (default to 'res'). If 'args' it will use the current arguments."},{"name":"__path","desc":"The path in __key where a map of replacements ([text/regexp]:[replace text]) can be found."},{"name":"inputKey","desc":"If defined, indicates the key that holds the string of data to replace."},{"name":"inputPath","desc":"If defined with inputKey, indicates the path to use to select the string of data to replace."},{"name":"inputFile","desc":"If defined the contents to be replaced will be read from the inputFile."},{"name":"outputFile","desc":"If defined will output of the content replacement to the defined file."},{"name":"useRegExp","desc":"Boolean value to determine if the map of replacements will be interpreted as a regexp or text."},{"name":"flagsRegExp","desc":"If useRegExp=true the JavaScript reg exp flags to use (defaults to 'g')"},{"name":"logJob","desc":"Optionally provide a logging job with the current args and __op with 'read' or 'write'"}],"returns":[{"name":"output","desc":"If outputFile is not defined the output will contain the content replacement"}]},"check":{"in":{"__key":"default(\"res\")","__path":"isString.default(\"@\")","inputKey":"isString.default(__)","inputPath":"isString.default(__)","inputFile":"isString.default(__)","outputFile":"isString.default(__)","useRegExp":"toBoolean.isBoolean.default(false)","flagsRegExp":"isString.default(\"g\")","logJob":"default(__)"}},"exec":"var b=isMap(args.__key)?args.__key:$path(\"args\"==args.__key?args:$get(args.__key),args.__path);_$(b,\"__key data\").isMap().$_();if(isUnDef(args.inputKey)&&isUnDef(args.inputFile))throw\"Need args inputKey or inputFile\";args.__op=\"read\";isDef(args.logJob)&&$job(args.logJob,args);var a=isDef(args.inputKey)?$path(\"args\"==args.inputKey?args:$get(args.inputKey),args.inputPath):io.readFileString(args.inputFile);Object.keys(b).forEach(function(c){a=a.replace(new RegExp(args.useRegExp?c:c.replace(/[.*+?^${}()|[\\]\\\\]/g,\n\"\\\\$&\"),args.useRegExp?args.flagsRegExp:\"g\"),b[c])});args.__op=\"write\";isDef(args.logJob)&&$job(args.logJob,args);isDef(args.outputFile)?io.writeFileString(args.outputFile,a):args.output=a"},{"name":"ojob channel","typeArgs":{"shortcut":{"name":"ch","keyArg":"__name","args":{"op":"__op","key":"__key","kpath":"__kpath","k":"key","ks":"keys","v":"value","vs":"values","vpath":"__vpath","extra":"extra"}}},"help":{"text":"Provides a set of operations over an OpenAF channel","expects":[{"name":"__name","desc":"The name of the OpenAF channel to use","required":true},{"name":"__op","desc":"The operation to perform (e.g. setall, set, get, unset, unsetall, getkeys, getall and size)","required":true},{"name":"__key","desc":"The key from where to retrieve the operation arguments (args to retrive from arguments)"},{"name":"__kpath","desc":"If defined, the path over the values retrieved from __key where the key or keys of the operation are defined"},{"name":"key","desc":"If defined, the key to use with the operations set, get and unset"},{"name":"keys","desc":"If defined, the set of fields to use with the operations setall and unsetall"},{"name":"value","desc":"If defined, the value to use with the operations set, get and unset"},{"name":"values","desc":"If defined, an array of values to use with the operations setall and unsetall"},{"name":"__vpath","desc":"If defined, the path over the values retrieved from __key where the value or values of the operation are defined"},{"name":"extra","desc":"If defined, will provide an extra argument (usually a map), depending on channel type, for the getall and getkeys operations."}],"returns":[{"name":"_list","desc":"If __key == 'args' will return the results of getall and getkeys"},{"name":"_map","desc":"If __key == 'args' will return the results of get"},{"name":"size","desc":"If __key == 'args' will return the size of the channel"}]},"check":{"in":{"__name":"isString","__op":"isString","key":"default(__)","keys":"default(__)","value":"default(__)","values":"default(__)","__kpath":"isString.default(__)","__vpath":"isString.default(__)","extra":"default(__)","__key":"default(\"res\")"}},"exec":"var a=function(){var b={k:__,v:__};isDef(args.key)&&(b.k=args.key);isDef(args.keys)&&(b.k=args.keys);isDef(args.value)&&(b.v=args.value);isDef(args.values)&&(b.v=args.values);\"args\"==args.__key?(isDef(args.__kpath)&&(b.k=$path(args,args.__kpath)),isDef(args.__vpath)&&(b.v=$path(args,args.__vpath))):(isDef(args.__kpath)&&(b.k=$path($get(args.__key),args.__kpath)),isDef(args.__vpath)&&(b.v=$path($get(args.__key),args.__vpath)));return b};switch(args.__op.toLowerCase()){case \"getall\":a=$ch(args.__name).getAll(args.extra);\nisUnDef(a)&&(a=[]);\"args\"!=args.__key?$set(args.__key,a):args._list=a;break;case \"setall\":a=a();$ch(args.__name).setAll(a.k,a.v);break;case \"set\":a=a();$ch(args.__name).set(a.k,a.v);break;case \"get\":a=a();a=$ch(args.__name).get(a.k);isUnDef(a)&&(a={});\"args\"!=args.__key?$set(args.__key,a):args._map=a;break;case \"unset\":a=a();$ch(args.__name).unset(a.k);break;case \"unsetall\":a=a();$ch(args.__name).unsetAll(a.k,a.v);break;case \"getkeys\":a=$ch(args.__name).getKeys(args.extra);isUnDef(a)&&(a=[]);\"args\"!=\nargs.__key?$set(args.__key,a):args._list=a;break;case \"size\":a=$ch(args.__name).size(),isUnDef(a)&&(a=-1),\"args\"!=args.__key?$set(args.__key,a):args.size=a}"},{"name":"ojob print","typeArgs":{"noLog":true,"shortcut":{"name":"print","keyArg":"msg","args":{"key":"__key","path":"__path","level":"level"}}},"help":{"text":"Prints a message line given an OpenAF template","expects":[{"name":"__key","desc":"Map key to retrieve ('args' for arguments)"},{"name":"__path","desc":"The path to consider from the __key"},{"name":"msg","desc":"The message template to use","required":true},{"name":"level","desc":"The level of the message (info (default) or error)"}]},"check":{"in":{"__key":"isString.default(\"res\")","__path":"isString.default(\"@\")","msg":"isString","level":"isString.oneOf([\"info\",\"error\"]).default(\"info\")"}},"exec":"var a=\"args\"==args.__key?$path(args,args.__path):$path($get(args.__key),args.__path);switch(args.level){case \"error\":tprintErr(args.msg,a);break;case \"info\":tprint(args.msg,a)}"},{"name":"ojob print md","typeArgs":{"noLog":true,"shortcut":{"name":"printmd","keyArg":"__text","args":{"outputMD":"__outputMD"}}},"help":{"text":"Parses an input text as simple ascii markdown","expects":[{"name":"__text","desc":"The text template to parse."},{"name":"__outputMD","desc":"A boolean flag that if true will no parse the input text"}]},"check":{"in":{"__text":"isString","__outputMD":"toBoolean.isBoolean.default(false)"}},"exec":"var a=clone(args);delete a.__text;args.__outputMD?printnl($t(args.__text,a)):printnl(ow.format.withMD($t(args.__text,a)));Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob log","typeArgs":{"noLog":true,"shortcut":{"name":"log","keyArg":"msg","args":{"key":"__key","path":"__path","level":"level","options":"options"}}},"help":{"text":"Logs a message line given an OpenAF template","expects":[{"name":"__key","desc":"Map key to retrieve ('args' for arguments)"},{"name":"__path","desc":"The path to consider from the __key"},{"name":"msg","desc":"The message template to use","required":true},{"name":"level","desc":"The level of the message (info (default), warn or error)"},{"name":"options","desc":"Extra options to provide to the tlog* functions. See more in the help of tlog, tlogErr and tlogWarn."}]},"check":{"in":{"__key":"isString.default(\"res\")","__path":"isString.default(\"@\")","msg":"isString","level":"isString.oneOf([\"info\",\"warn\",\"error\"]).default(\"info\")","options":"isMap.default({})"}},"exec":"var a=\"args\"==args.__key?$path(args,args.__path):$path($get(args.__key),args.__path);switch(args.level){case \"warn\":tlogWarn(args.msg,a,args.options);break;case \"error\":tlogErr(args.msg,a,args.options);break;case \"info\":tlog(args.msg,a,args.options)}"},{"name":"ojob function","typeArgs":{"noLog":true,"shortcut":{"name":"fn","keyArg":"__fn","args":{"key":"__key","path":"__path","fnPath":"__fnPath"}}},"help":{"text":"Executes the provided function mapping any args to the function arguments using the odoc help available for the provided function.\nNote: accessing odoc might be slow on a first execution.\n","expects":[{"name":"__key","desc":"The key string to retrieve previous results (defaults to 'res')","required":true},{"name":"__fn","desc":"The function to execute"},{"name":"__path","desc":"If defined the args path for the function arguments to consider"},{"name":"__fnPath","desc":"If defined the args path where to set the function result"}]},"check":{"in":{"__fn":"isString","__key":"isString.default(\"res\")"}},"exec":"0>args.__fn.indexOf(\".\")&&(args.__fn=\"global.\"+args.__fn);var a=$fnM(args.__fn,isDef(args.__path)?$path(args,args.__path):args);isString(args.__fnPath)&&(a=$$({}).set(args.__fnPath,a));isString(args.__key)?$set(args.__key,a):args=merge(args,a);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob output","typeArgs":{"noLog":true,"shortcut":{"name":"output","keyArg":"__key","args":{"path":"__path","format":"__format","title":"__title","internal":"__internal","query":"__query","csv":"__csv","function":"__function"}}},"help":{"text":"Prints the current arguments to the console.","expects":[{"name":"__key","desc":"The key string to retrieve previous results (defaults to 'res'). If \"args\" will retrieve from current args."},{"name":"__path","desc":"A path string to a map/array over the results set on key."},{"name":"__format","desc":"The output format (e.g. see ow.oJob.output help)"},{"name":"__title","desc":"Encapsulates the output map/array with a title key."},{"name":"__internal","desc":"Boolean value that if true it will display the internal oJob entries on the arguments (default false)"},{"name":"__function","desc":"One of the OpenAF's print or log functions available"}]},"exec":"isUnDef(args.__key)&&isDef(args.key)&&(args.__key=args.key);isUnDef(args.__path)&&isDef(args.path)&&(args.__path=args.path);isUnDef(args.__format)&&isDef(args.format)&&(args.__format=args.format);isUnDef(args.__title)&&isDef(args.title)&&(args.__title=args.title);isUnDef(args.__internal)&&isDef(args.internal)&&(args.__internal=args.internal);if(isString(args.__function))if(0<=args.__function.indexOf(\"print\")||0<=args.__function.indexOf(\"log\")){if(!(0<=af.fromJavaArray(af.getScopeIds()).map(function(b){return String(b)}).indexOf(args.__function)))throw\"__function '\"+\nargs.__function+\"' not found.\";args.__function=global[args.__function]}else throw\"__function needs to be a 'print' or 'log' function\";else args.__function=__;args.__key=_$(args.__key,\"key\").isString().default(\"res\");\"\"==args.__key&&(args.__key=\"res\");var a=\"args\"==args.__key?args:$get(args.__key);isUnDef(a)&&(a=args);!isDef(a)||isNull(a)||toBoolean(args.__internal)||(delete a.objId,delete a.execid,delete a.id);isDef(args.format)&&(args.__format=args.format,delete args.format);isDef(args.__path)&&\n(a=$path(a,args.__path),delete args.__path);isMap(a)&&isDef(a._list)&&(a=a._list);isMap(a)&&isDef(a._map)&&(a=a._map);if(isDef(args.__title)){var c={};c[args.__title]=a;ow.oJob.output(c,args,args.__function)}else ow.oJob.output(a,args,args.__function);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob final report","to":"ojob report","type":"shutdown","help":{"text":"Outputs a jobs report (e.g. job name, status, number of executions, total time, avg time and last execution) upon ojob termination","expects":[{"name":"__format","desc":"Can be json, yaml, table (default) or any other ow.oJob.output format"}]}},{"name":"ojob final deps report","to":"ojob deps report","type":"shutdown","help":{"text":"Outputs a tree list for each defined job (excluding \"ojob *\") and a comma delimited list of dependencies with a status flag"}},{"name":"ojob deps report","help":{"text":"Outputs a tree list for each defined job (excluding \"ojob *\") and a comma delimited list of dependencies with a status flag"},"exec":"var b={};$from($ch(\"oJob::log\").getAll()).notStarts(\"name\",\"ojob \").select(function(a){b[a.name]=a.start?a.success?ansiColor(\"GREEN\",\"\\u2713\"):a.deps?a.error?ansiColor(\"RED\",\"\\u2715\"):ansiColor(\"BLUE\",\"\\u25b7\"):ansiColor(\"RED\",\"\\u2715\"):ansiColor(\"YELLOW\",\"\\u23f8\")});var c={};$from($ch(\"oJob::jobs\").getAll()).notStarts(\"name\",\"ojob \").select(function(a){c[a.name]=a.deps.map(function(d){return b[d]+\" \"+d}).join(\", \")});ow.oJob.output(c,{__format:\"tree\"})"},{"name":"ojob report","help":{"text":"Outputs a jobs report (e.g. job name, status, number of executions, total time, avg time and last execution)","expects":[{"name":"__format","desc":"Can be json, yaml, table (default) or any other ow.oJob.output format"}]},"exec":"ow.loadFormat();print(\"\\n\");var b=$ch(\"oJob::log\").getAll(),c=$from(b).notEquals(\"name\",\"ojob report\").notEquals(\"name\",\"ojob final report\").select(function(a){return{\"Job name\":a.name,Status:a.start?a.success?\"OK\":a.deps?a.error?\"NOT OK!\":\"executing\":\"failed deps\":\"not started\",\"# execs\":a.count,\"Total time\":ow.format.elapsedTime4ms(a.totalTime,{abrev:!0}),\"Avg time\":ow.format.elapsedTime4ms(a.avgTime,{abrev:!0}),\"Last exec\":0args.validStates.indexOf(args.state)&&(isDef(args.default)?args.state=args.default:args.state=__);isString(args.state)&&isDef(ow.oJob.setState)&&ow.oJob.setState(args.state)"},{"name":"ojob todo","typeArgs":{"noLog":true,"shortcut":{"name":"todo","keyArg":"todo","args":{"isolateArgs":"isolateArgs","isolateJob":"isolateJob","templateArgs":"templateArgs","shareArgs":"shareArgs","debug":"__debug"}}},"help":{"text":"Executes an ojob sub-todo.\nNOTE: doesn't perform any checks for recursive behaviour!","expects":[{"name":"todo","desc":"A string or array of todo' maps"},{"name":"todo[].name","desc":"Name of the job to execute"},{"name":"todo[].args","desc":"Arguments to merge (if isolateArgs is not true) with the main job arguments"},{"name":"todo[].isolateArgs","desc":"Boolean to indicate, for a specific todo, that args should be isolated from all others"},{"name":"todo[].isolateJob","desc":"Boolean to indicate, for a specific todo, that the job should run in a different scope (e.g. deps will not work)"},{"name":"todo[].templateArgs","desc":"Boolean to indicate, for a specific todo, to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"isolateArgs","desc":"Boolean, false by default, to indicate that args should be isolated from all others"},{"name":"isolateJob","desc":"Boolean, false by default, to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean, true by default, to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"shareArgs","desc":"Boolean, false by default, to indicate that args should be shared between all todo's jobs sequentially."},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"check":{"in":{"isolateArgs":"toBoolean.isBoolean.default(false)","isolateJob":"toBoolean.isBoolean.default(false)","templateArgs":"toBoolean.isBoolean.default(true)","shareArgs":"toBoolean.isBoolean.default(false)","__debug":"toBoolean.isBoolean.default(false)"}},"exec":"if(!isString(args.todo)&&!isArray(args.todo))throw\"todo needs to be a string or an array\";isString(args.todo)&&(args.todo=[args.todo]);var a=clone(args);delete a.todo;delete a.isolateArgs;delete a.templateArgs;delete a.shareArgs;delete a.__debug;args.todo.forEach(function(b){if(!isMap(b)&&!isString(b))throw\"todo entry needs to be a map or a string (\"+af.toSLON(b)+\")\";b=$job(\"ojob run\",{job:b,id:ow.oJob.__id,isolateArgs:args.isolateArgs,isolateJob:args.isolateJob,templateArgs:args.templateArgs,\n__debug:args.__debug,args:a});args.shareArgs&&(a=merge(a,b))})"},{"name":"ojob run","typeArgs":{"noLog":true},"check":{"in":{"job":"default(__)","id":"isString.default(ow.oJob.__id)","isolateArgs":"toBoolean.isBoolean.default(false)","isolateJob":"toBoolean.isBoolean.default(false)","templateArgs":"toBoolean.isBoolean.default(true)","__debug":"toBoolean.isBoolean.default(false)"}},"help":{"text":"Executes an ojob but alternatively use 'ojob todo' or $job for most functionality.","expects":[{"name":"job","desc":"Name of the job to execute"},{"name":"id","desc":"The oJob id to execute (leave undefined to default to the current one)"},{"name":"args","desc":"The args to consider on execution."},{"name":"isolateArgs","desc":"Boolean to indicate that args should be isolated."},{"name":"isolateJob","desc":"Boolean to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"exec":"if(!isString(args.job)&&!isMap(args.job))throw\"job needs to be either a string or job map\";isString(args.job)&&(args.job={name:args.job});args.job.templateArgs=_$(args.job.templateArgs,\"templateArgs \"+args.job.name).isBoolean().default(args.templateArgs);args.job.isolateArgs=_$(args.job.isolateArgs,\"isolateArgs \"+args.job.name).isBoolean().default(args.isolateArgs);args.job.isolateJob=_$(args.job.isolateJob,\"isolateJob \"+args.job.name).isBoolean().default(args.isolateJob);args.job.templateArgs&&\nisDef(args.args)&&args.job.templateArgs&&isDef(args.job.args)&&(isString(args.job.args)&&(args.job.args=ow.oJob.__processArgs(args.job.args)),traverse(args.job.args,function(c,b,e,d){isString(b)&&(d[c]=templify(b,args))}));args.job=ow.oJob.parseTodo(args.job);var a={name:args.job.name,args:args.job.isolateArgs?args.job.args:merge(args.args,args.job.args),id:args.job.isolateJob?__:args.id};args.__debug&&cprint(ow.format.withSideLine(printTreeOrS(a,__,{bgcolor:\"BG(235)\"}),__,\"FG(240)\",\"BG(235)\",ow.format.withSideLineThemes().openBottomCurvedRect));\nargs=merge(args,$job(a.name,a.args,a.id))"},{"name":"ojob run file","typeArgs":{"noLog":true,"shortcut":{"name":"runfile","keyArg":"__job","args":{"args":"__args","out":"__out","key":"__key","inKey":"__inKey","usePM":"__usePM","inPM":"__inPM","templateArgs":"__templateArgs","debug":"__debug"}}},"help":{"text":"Executes an external YAML/JSON ojob file or a remote URL with the provided args.","expects":[{"name":"__job","desc":"The YAML/JSON ojob file or remote URL to run"},{"name":"__args","desc":"The args to provide to the external ojob file/url"},{"name":"__out","desc":"The path on args to set the map key/path contents"},{"name":"__key","desc":"If __out is not defined will set the content into the provided key"},{"name":"__inKey","desc":"If defined, args will be merged with the content from the provided key"},{"name":"__usePM","desc":"Output to __pm"},{"name":"__inPM","desc":"Input from provided key to __pm"},{"name":"__templateArgs","desc":"Boolean to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"__debug","desc":"Boolean to indicate that the job execution parameters should be printed before executing"}]},"check":{"in":{"__job":"isString","__args":"isMap.default({})","__out":"isString.default(__)","__key":"isString.default(\"res\")","__inKey":"isString.default(__)","__usePM":"toBoolean.isBoolean.default(false)","__inPM":"isString.default(__)","__templateArgs":"toBoolean.isBoolean.default(false)","__debug":"toBoolean.isBoolean.default(false)"}},"exec":"var c=\"args\"==args.__key?\"r\"+nowNano():args.__key;args.__templateArgs&&isDef(args.__args)&&traverse(args.__args,function(b,d,g,f){isString(d)&&(f[b]=templify(d,args))});if(args.__usePM){var a={__format:\"pm\"};args.__key=__;args.__usePM=__}else a={__format:\"key\",__key:c};if(isDef(args.__inKey)){var e=$get(args.__inKey);a=merge(isDef(e)?merge(args.__args,e):args.__args,a)}else a=merge(args.__args,a);isDef(args.__inPM)&&ow.oJob.output($get(args.__inPM),{__format:\"pm\"});args.__debug&&cprint(ow.format.withSideLine(printTreeOrS(a,\n__,{bgcolor:\"BG(235)\"}),__,\"FG(235)\",\"BG(235)\",ow.format.withSideLineThemes().openBottomCurvedRect));ow.oJob.runFile(args.__job,a,c,!0,{shareArgs:!1});if(\"args\"==args.__key||\"res\"==args.__key)a=$get(c),isDef(a)&&(delete a.__format,delete a.__key,args=merge(args,a),\"args\"==args.__key&&$unset(c));Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob parallel","typeArgs":{"noLog":true,"shortcut":{"name":"parallel","keyArg":"todo"}},"help":{"text":"Executes an ojob sub-todo in parallel.\nNOTE: doesn't perform any checks for recursive behaviour!","expects":[{"name":"todo","desc":"A string or array of todo' maps"},{"name":"todo[].name","desc":"Name of the job to execute"},{"name":"todo[].args","desc":"Arguments to merge (if isolateArgs is not true) with the main job arguments"},{"name":"todo[].isolateArgs","desc":"Boolean to indicate, for a specific todo, that args should be isolated from all others"},{"name":"todo[].isolateJob","desc":"Boolean to indicate, for a specific todo, that the job should run in a different scope (e.g. deps will not work)"},{"name":"todo[].templateArgs","desc":"Boolean to indicate, for a specific todo, to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"isolateArgs","desc":"Boolean, false by default, to indicate that args should be isolated from all others"},{"name":"isolateJob","desc":"Boolean, false by default, to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean, true by default, to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"shareArgs","desc":"Boolean, false by default, to indicate that args should be shared between all todo's jobs sequentially."},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"check":{"in":{"isolateArgs":"toBoolean.isBoolean.default(false)","isolateJob":"toBoolean.isBoolean.default(false)","templateArgs":"toBoolean.isBoolean.default(true)","shareArgs":"toBoolean.isBoolean.default(false)","__debug":"toBoolean.isBoolean.default(false)"}},"exec":"if(!isString(args.todo)&&!isArray(args.todo))throw\"todo needs to be a string or an array\";isString(args.todo)&&(args.todo=[args.todo]);var a=clone(args),c=[];delete a.todo;delete a.isolateArgs;delete a.templateArgs;delete a.shareArgs;delete a.__debug;args.todo.forEach(function(b){if(!isMap(b)&&!isString(b))throw\"todo entry needs to be a map or a string (\"+af.toSLON(b)+\")\";c.push($do(function(){return $job(\"ojob run\",{job:b,id:ow.oJob.__id,isolateArgs:args.isolateArgs,isolateJob:args.isolateJob,\ntemplateArgs:args.templateArgs,__debug:args.__debug,args:a})}))});$doWait($doAll(c))"},{"name":"ojob wait","typeArgs":{"noLog":true,"shortcut":{"name":"wait","keyArg":"time"}},"help":{"text":"Waits for a specific amount of time","expects":[{"name":"time","desc":"The amount of time, in ms, to pause execution"}]},"check":{"in":{"time":"toNumber.isNumber"}},"exec":"sleep(args.time,!0)"},{"name":"ojob exit","typeArgs":{"noLog":true,"shortcut":{"name":"fail","keyArg":"code","args":{"force":"force"}}},"help":{"text":"Ends all processing with an exit code","expects":[{"name":"code","desc":"The exit code number to use"},{"name":"force","desc":"A boolean indicating if instead of exit the processing should halt"}]},"check":{"in":{"code":"toNumber.isNumber.default(0)","force":"toBoolean.isBoolean.default(false)"}},"exec":"exit(args.code,args.force)"},{"name":"ojob convert","typeArgs":{"noLog":false,"shortcut":{"name":"convert","keyArg":"__inKey","args":{"inPath":"__inPath","inFormat":"__inFormat","outPath":"__outPath","outKey":"__outKey"}}},"check":{"in":{"__inPath":"isString.default(\"\")","__inKey":"isString.default(\"res\")","__inFormat":"isString.oneOf(['yaml','json','xml','ndjson','slon'])","__outPath":"isString.default(__)","__outKey":"isString.default(__)"}},"help":{"text":"Converts string content into an internal object (map/array)","expects":[{"name":"__inKey","desc":"Where to find the input contents to convert (if 'args' will default to the current args)"},{"name":"__inPath","desc":"The path on the input contents for the string to convert"},{"name":"__inFormat","desc":"The format of the input contents (yaml, json, xml, ndjson, slon)"},{"name":"__outKey","desc":"Where the converted output object should be placed (if 'args' with default to the current args)"},{"name":"__outPath","desc":"The path on the output contents to store the converted object"}]},"exec":"var c=\"args\"!=args.__inKey?String($$(args).get(args.__inPath)):String($$($get(args.__inKey)).get(args.__inPath));isUnDef(args.__outKey)&&(args.__outKey=args.__inKey);isUnDef(args.__outPath)&&(args.__outPath=args.__inPath);switch(args.__inFormat){case \"yaml\":_$(c,\"yaml input\").isString().$_();var a=af.fromYAML(c);break;case \"json\":a=jsonParse(c,!0);break;case \"ndjson\":a=c.split(\"\\n\").map(function(b){return jsonParse(b,!0)}).filter(function(b){return isDef(b)&&!isNull(b)});break;case \"xml\":a=\naf.fromXML2Obj(a);break;case \"slon\":a=af.fromSLON(a);break;default:throw\"No inFormat provided.\";}\"args\"!=args.__outKey?$$(args).set(args.__outPath,a):($get(args.outKey),$$(o).set(args.outPath,a),$set(args.outKey,o));Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"}]} \ No newline at end of file +{"jobs":[{"name":"ojob pass","typeArgs":{"noLog":true,"shortcut":{"name":"pass","keyArg":"__args","args":{"debug":"__debug","templateArgs":"__templateArgs"}}},"help":{"text":"Placeholder/pass job to allow for arguments injection","expects":[{"name":"__args","desc":"The args to inject"},{"name":"__debug","desc":"Boolean to indicate that args to be inject should be printed before"},{"name":"__templateArgs","desc":"Boolean, true by default, to indicate to apply template to each string in args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"}]},"check":{"in":{"__args":"isMap.default({})","__debug":"toBoolean.isBoolean.default(false)","__templateArgs":"toBoolean.isBoolean.default(true)"}},"exec":"var b=clone(args.__args);args.__templateArgs?traverse(b,function(c,a,e,d){isNull(a)&&(d[c]=__);isString(a)&&0<=a.indexOf(\"{{\")&&(d[c]=templify(a,args))}):traverse(b,function(c,a,e,d){isNull(a)&&(d[c]=__)});args.__debug&&cprint(ow.format.withSideLine(printTreeOrS(b,__,{bgcolor:\"BG(235)\"}),__,\"FG(240)\",\"BG(235)\",ow.format.withSideLineThemes().openBottomCurvedRect));delete args.__argsp;delete args.__debug;delete args.__templateArgs;args=merge(args,b)"},{"name":"ojob debug","typeArgs":{"noLog":true,"shortcut":{"name":"jobdebug","keyArg":"job","args":{"lineColor":"lineColor","textColor":"textColor","theme":"theme","emoticons":"emoticons","signs":"signs","includeTime":"includeTime"}}},"help":{"text":"Outputs the current args and res values to help debug an ojob flow."},"exec":"ow.loadFormat();print(\"\");cprint(ow.format.withSideLine(\"ARGS:\",__,\"FG(240)\",\"BG(240),BOLD\",ow.format.withSideLineThemes().openBottomCurvedRect));cprint(ow.format.withSideLine(colorify(args,{bgcolor:\"BG(235)\"}),__,\"FG(240)\",\"BG(235)\",ow.format.withSideLineThemes().openTopCurvedRect));cprint(ow.format.withSideLine(\"RES:\",__,\"FG(240),BOLD\",\"BG(240),BOLD\",ow.format.withSideLineThemes().openBottomCurvedRect));cprint(ow.format.withSideLine(colorify($get(\"res\"),{bgcolor:\"BG(235)\"}),__,\"FG(240)\",\n\"BG(235)\",ow.format.withSideLineThemes().openTopCurvedRect))"},{"name":"ojob job debug","typeArgs":{"noLog":true,"shortcut":{"name":"jobsdebug","keyArg":"jobs","args":{"lineColor":"lineColor","textColor":"textColor","theme":"theme","emoticons":"emoticons","signs":"signs","includeTime":"includeTime"}}},"help":{"text":"Provides an alternative to print based debug.\n\nExample:\n # ----------------\n - name: Sample job\n exec: |\n //@ Declaring array\n var ar = [ 0, 1, 2, 3, 4, 5 ]\n\n //@ Start cycle\n var ii = 0;\n while(ii < ar.length) {\n print(\"II = \" + ii)\n ii++\n //# ii == 3\n }\n //@ End cycle\n //? ii\n\n //?s args\n //?y args\n","expects":[{"name":"job","desc":"The job to change to include debug"},{"name":"jobs","desc":"The jobs array to change to include debug"},{"name":"lineColor","desc":"The line color around the debug info"},{"name":"textColor","desc":"The text color around the debug info"},{"name":"theme","desc":"The withSideLineThemes theme to use"},{"name":"emoticons","desc":"If emoticons should be used or not"},{"name":"signs","desc":"A custom map of emoticons (keys: checkpoint, assert and print)"},{"name":"includeTime","desc":"A boolean value to indicate if a time indication should be included"}]},"check":{"in":{"job":"isString.default(__)","jobs":"isArray.default([])","lineColor":"isString.default(\"FG(220)\")","textColor":"isString.default(\"BG(230),BLACK\")","lineError":"isString.default(\"FG(220)\")","textError":"isString.default(\"BG(196),FG(255),BOLD\")","theme":"isString.default(\"doubleLineBothSides\")","emoticons":"toBoolean.isBoolean.default(true)","signs":"isMap.default(__)","includeTime":"toBoolean.isBoolean.default(false)"}},"exec":"isMap(void 0)&&(args=merge(void 0,args));args.signs=_$(args.signs,\"signs\").isMap().default({checkpoint:127866,assert:128077,print:128270,error:128545,time:\"\\ud83d\\udd52\"});isDef(args.job)&&0==args.jobs.length&&args.jobs.push(args.job);if(isUnDef(getEnv(\"OJOB_DEBUG\"))||toBoolean(getEnv(\"OJOB_DEBUG\"))){ow.loadFormat();var h=ow.oJob.getJobsCh();0==args.jobs.length&&(args.jobs=h.getKeys().filter(function(e){return\"ojob job debug\"!=e.name}).map(function(e){return e.name}));var k=!1;isDef(ow.loadDebug)&&\n(ow.loadDebug(),ow.debug.register(),k=!0);args.jobs.forEach(function(e){var d=h.get({name:e});if(k){if(isUnDef(d.lang)||isDef(d.lang)&&(\"oaf\"==d.lang||\"js\"==d.lang))d.exec=ow.debug.debug(d.exec,args,!0)}else{var f=function(c,a){var g=\";try{\";isDef(a)&&(g+=\"if(\"+a+\") {\");var l=args.includeTime?'(new Date()).toISOString() +\" | \" + ':\"\";g+=\"cprint(ow.format.withSideLine(\"+l+c+', __, \"'+args.lineColor+'\", \"'+args.textColor+'\", ow.format.withSideLineThemes().'+args.theme+\")) \";isDef(a)&&(g+=\"}\");return g+=\n\"}catch(__e_debug){cprint(ow.format.withSideLine(\"+l+\"' \"+b.error+\" ' + String(__e_debug), __, \\\"\"+args.lineError+'\", \"'+args.textError+'\", ow.format.withSideLineThemes().'+args.theme+\"))};\"};if(args.emoticons){var b=args.signs;isNumber(b.checkpoint)&&(b.checkpoint=ow.format.string.unicode(b.checkpoint));isNumber(b.assert)&&(b.assert=ow.format.string.unicode(b.assert));isNumber(b.print)&&(b.print=ow.format.string.unicode(b.print));isNumber(b.error)&&(b.error=ow.format.string.unicode(b.error))}b.checkpoint=\n_$(b.checkpoint).default(\"@\");b.assert=_$(b.assert).default(\"#\");b.print=_$(b.print).default(\"?\");b.error=_$(b.error).default(\"!\");d.exec=d.exec.split(\"\\n\").map(function(c){var a=c.trim().match(/\\/\\/@ (.+)$/);isArray(a)&&(a=a[1],c=c.replace(/\\/\\/@ (.+)$/,f('\" '+b.checkpoint+\" \"+a.replace(/\"/g,'\\\\\"')+'\"')));a=c.trim().match(/\\/\\/# (.+)$/);isArray(a)&&(a=a[1],c=c.replace(/\\/\\/# (.+)$/,f('\" '+b.assert+\" \"+a+'\"',a)));a=c.trim().match(/\\/\\/\\? (.+)$/);isArray(a)&&(a=a[1],c=c.replace(/\\/\\/\\? (.+)$/,f('\" '+\nb.print+\" \"+a+' = \" + stringify('+a+') + \"\"')));a=c.trim().match(/\\/\\/\\?s (.+)$/);isArray(a)&&(a=a[1],c=c.replace(/\\/\\/\\?s (.+)$/,f('\" '+b.print+\" \"+a+' = \" + af.toSLON('+a+') + \"\"')));a=c.trim().match(/\\/\\/\\?y (.+)$/);isArray(a)&&(a=a[1],c=c.replace(/\\/\\/\\?y (.+)$/,f('\" '+b.print+\" \"+a+' = \" + af.toYAML('+a+') + \"\"')));return c}).join(\"\\n\")}h.set({name:e},d)})}"},{"name":"ojob get pm","args":{"__key":"args"},"check":{"in":{"__key":"isString.default(\"res\")"}},"exec":"var a=__pm;isDef(__pm._map)&&(a=__pm._map);isDef(__pm._list)&&(a=__pm._list);\"args\"==args.__key?args=merge(args,a):$set(args.__key,a);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob get","typeArgs":{"shortcut":{"name":"get","keyArg":"__key","args":{"path":"__path"}}},"help":{"text":"Retrieves a specific map key (or path) using $get","expects":[{"name":"__key","desc":"Map key to retrieve (key is also checked for compatibility)"},{"name":"__path","desc":"The path to consider from the __key"}]},"check":{"in":{"__key":"isString.default(\"res\")","__path":"isString.default(\"@\")"}},"exec":"isUnDef(args.__key)&&isDef(args.key)&&(args.__key=args.key);var a=\"args\"==args.__key?$path(args,args.__path):$path($get(args.__key),args.__path);isArray(a)&&(a={_list:a});args=merge(args,a);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob set","typeArgs":{"shortcut":{"name":"set","keyArg":"__key","args":{"path":"__path"}}},"help":{"text":"Sets a \"key\" with the current value on a \"path\" using $set","expects":[{"name":"__key","desc":"Map key"},{"name":"__path","desc":"A key or path to a value from the current args"}]},"check":{"in":{"__key":"isString.default(\"res\")","__path":"isString"}},"exec":"var b=$path(args,args.__path);isDef(b)&&\"args\"!=args.__key&&$set(args.__key,b);Object.keys(args).filter(function(a){return a.startsWith(\"__\")}).forEach(function(a){return delete args[a]})"},{"name":"ojob unset","typeArgs":{"shortcut":{"name":"unset","keyArg":"__key"}},"help":{"text":"Unsets a \"key\" using $unset","expects":[{"name":"__key","desc":"Map key"}],"check":{"in":{"__key":"isString.default(\"res\")"}}},"exec":"$unset(args.__key);Object.keys(args).filter(function(a){return a.startsWith(\"__\")}).forEach(function(a){return delete args[a]})"},{"name":"ojob file get","typeArgs":{"noLog":true,"shortcut":{"name":"fileget","keyArg":"__file","args":{"path":"__path","cache":"__cache","ttl":"__ttl","out":"__out","key":"__key"}}},"help":{"text":"Retrieves a specific map key (or path) from an YAML or JSON file provided.","expects":[{"name":"__file","desc":"The file path to an YAML or JSON file","required":true},{"name":"__path","desc":"Path of the file contents"},{"name":"__cache","desc":"Boolean value that if false it won't cache the file contents (default: true)"},{"name":"__ttl","desc":"If cache is enabled lets you define a numeric ttl"},{"name":"__out","desc":"The path on args to set the map key/path contents"},{"name":"__key","desc":"If __out is not defined will set the content into the provided key"}]},"check":{"in":{"__file":"isString","__path":"isString.default(\"@\")","__cache":"toBoolean.isBoolean.default(true)","__ttl":"isNumber.default(__)","__out":"isString.default(__)","__key":"isString.default(\"res\")"}},"exec":"if(args.__cache){var c=$cache(\"__ojob_file_get\");isDef(args.__ttl)&&(c=c.ttl(args.__ttl));c=c.fn(function(a){return isDef(a.file)?a.file.endsWith(\".json\")?io.readFileJSON(a.file):/\\.ya?ml$/.test(a.file)?io.readFileYAML(a.file):{error:\"Not an yaml, yml or json file.\"}:{}}).create();var b=c.get({file:args.__file})}else b=args.__file.endsWith(\".json\")?io.readFileJSON(args.__file):/\\.ya?ml$/.test(args.__file)?io.readFileYAML(args.__file):{error:\"Not an yaml, yml or json file.\"};b=$path(b,\nargs.__path);isDef(args.__out)?$$(args).set(args.__out,b):isDef(args.__key)?$set(args.__key,b):Object.keys(b).forEach(function(a){return $$(args).set(a,b[a])});Object.keys(args).filter(function(a){return a.startsWith(\"__\")}).forEach(function(a){return delete args[a]})"},{"name":"ojob template","typeArgs":{"shortcut":{"name":"template","keyArg":"template","args":{"templateFile":"templateFile","data":"data","dataFile":"dataFile","outputFile":"outputFile","key":"__key","tpath":"__tpath","dpath":"__dpath","outPath":"__outPath","out":"__out"}}},"help":{"text":"Applies the OpenAF template over the provided data producing an output.","expects":[{"name":"__key","desc":"The key that holds template and/or data (default to 'res'). If 'args' it will use the current arguments."},{"name":"__tpath","desc":"The path in __key where a string with the template can be found."},{"name":"__dpath","desc":"The path in __key where a map/array data to use can be found."},{"name":"__out","desc":"The output will be stored into the provided key (defaults to 'res')"},{"name":"__outPath","desc":"If defined the $set path where __out will be set in the provided key."},{"name":"template","desc":"If defined, will be used as template"},{"name":"templateFile","desc":"If defined, it will use the provided template file."},{"name":"data","desc":"If defined, will be used as data"},{"name":"dataFile","desc":"If defined, it will use the provided data file (either yaml or json)."},{"name":"outputFile","desc":"If defined, the output will be written to the provided file path."}],"returns":[{"name":"output","desc":"If no outputFile is provided this will hold the output of applying the template with the provided data"}]},"check":{"in":{"__key":"isString.default(\"res\")","__tpath":"isString.default(\"@\")","__dpath":"isString.default(\"@\")","__out":"isString.default(\"res\")","__outPath":"isString.default(\"\")","templateFile":"isString.default(__)","dataFile":"isString.default(__)","outputFile":"isString.default(__)"}},"exec":"ow.loadTemplate();ow.template.addConditionalHelpers();ow.template.addFormatHelpers();ow.template.addOpenAFHelpers();var a=isDef(args.data)?args.data:\"args\"==args.__key?$path(args,args.__dpath):$path($get(args.__key),args.__dpath);isDef(args.dataFile)&&(a=args.dataFile.match(/\\.ya?ml$/i)?io.readFileYAML(args.dataFile):io.readFileJSON(args.dataFile));var b=isDef(args.template)?args.template:\"args\"==args.__key?$path(args,args.__tpath):$path($get(args.__key),args.__tpath);isDef(args.templateFile)&&\n(b=io.readFileString(args.templateFile));isDef(args.logJob)&&$job(args.logJob,args);a=templify(b,a);isDef(args.outputFile)?io.writeFileString(args.outputFile,a):\"args\"==args.__out?isDef(args.__outPath)?$$(args).set(args.__outPath,a):args.output=a:(b={},isDef(args.__outPath)&&$$(b).set(args.__outPath,a),b.output=a,$set(args.__out,b))"},{"name":"ojob template folder","typeArgs":{"shortcut":{"name":"templateFolder","keyArg":"templateFolder","args":{"templatePath":"__templatePath","data":"data","dataFile":"dataFile","outputFolder":"outputFolder","key":"__key","dpath":"__dpath","logJob":"logJob","metaTemplate":"metaTemplate"}}},"help":{"text":"Given a templateFolder it will execute 'ojob template' for each (recursively), with the provided data, to output to outputFolder. Optionally metaTemplate can be use where each json/yaml file in templateFolder all or part of the arguments for 'ojob template'.\n","expects":[{"name":"templateFolder","desc":"The original folder where the templates are located.","required":true},{"name":"__templatePath","desc":"If defined, will apply a $path string over the recursive list of files in templateFolder."},{"name":"outputFolder","desc":"The path where the output should be stored.","required":true},{"name":"data","desc":"If defined, will be used as data"},{"name":"dataFile","desc":"If defined, it will use the provided data file (either yaml or json)."},{"name":"__key","desc":"The key that holds template and/or data (default to 'res'). If 'args' it will use the current arguments."},{"name":"__dpath","desc":"The path in __key where a map/array data to use can be found."},{"name":"logJob","desc":"A ojob job to log the 'ojob template' activity (receives the same arguments as 'ojob template')"},{"name":"metaTemplate","desc":"Boolean that if 'true' will interpret any json/yaml file, in the templateFolder, as a map/array of arguments to use when calling 'ojob template' overriden the defaults."}]},"check":{"in":{"templateFolder":"isString","__templatePath":"isString.default(\"@\")","outputFolder":"isString","dataFile":"isString.default(__)","__key":"isString.default(\"res\")","__dpath":"isString.default(\"@\")","logJob":"isString.default(__)","metaTemplate":"toBoolean.isBoolean.default(false)"}},"exec":"var e=isDef(args.data)?args.data:\"args\"==args.__key?$path(args,args.__dpath):$path($get(args.__key),args.__dpath);isDef(args.dataFile)&&(e=args.dataFile.match(/\\.ya?ml$/i)?io.readFileYAML(args.dataFile):io.readFileJSON(args.dataFile));var b=[];$path(listFilesRecursive(args.templateFolder),args.__templatePath).forEach(function(a){var d={templateFile:a.filepath,outputFile:a.filepath.replace(new RegExp(\"^\"+args.templateFolder),args.outputFolder),data:e,logJob:args.logJob};args.metaTemplate&&\na.filename.match(/\\.(ya?ml|json)$/i)?(a=a.filename.match(/\\.ya?ml$/i)?io.readFileYAML(a.filepath):io.readFileJSON(a.filepath),delete d.templateFile,isMap(a)&&(isDef(a.outputFile)&&!a.outputFile.startsWith(\"/\")&&(a.outputFile=args.outputFolder+\"/\"+a.outputFile),b.push(merge(d,a))),isArray(a)&&(b=b.concat(a.map(function(c){isDef(c.outputFile)&&!c.outputFile.startsWith(\"/\")&&(c.outputFile=args.outputFolder+\"/\"+c.outputFile);return merge(d,c)})))):b.push(d)});io.mkdir(args.outputFolder);$job(\"ojob template\",\nb)"},{"name":"ojob find/replace","typeArgs":{"noLog":true,"shortcut":{"name":"findReplace","keyArg":"__key","args":{"path":"__path","inputKey":"inputKey","inputPath":"inputPath","inputFile":"inputFile","outputFile":"outputFile","useRegExp":"useRegExp","flagsRegExp":"flagsRegExp","logJob":"logJob"}}},"help":{"text":"Performs an in-memory find/replace on a provided string or file and outputs to args.output or, optionally, to a file.","expects":[{"name":"__key","desc":"The key that holds template and/or data (default to 'res'). If 'args' it will use the current arguments."},{"name":"__path","desc":"The path in __key where a map of replacements ([text/regexp]:[replace text]) can be found."},{"name":"inputKey","desc":"If defined, indicates the key that holds the string of data to replace."},{"name":"inputPath","desc":"If defined with inputKey, indicates the path to use to select the string of data to replace."},{"name":"inputFile","desc":"If defined the contents to be replaced will be read from the inputFile."},{"name":"outputFile","desc":"If defined will output of the content replacement to the defined file."},{"name":"useRegExp","desc":"Boolean value to determine if the map of replacements will be interpreted as a regexp or text."},{"name":"flagsRegExp","desc":"If useRegExp=true the JavaScript reg exp flags to use (defaults to 'g')"},{"name":"logJob","desc":"Optionally provide a logging job with the current args and __op with 'read' or 'write'"}],"returns":[{"name":"output","desc":"If outputFile is not defined the output will contain the content replacement"}]},"check":{"in":{"__key":"default(\"res\")","__path":"isString.default(\"@\")","inputKey":"isString.default(__)","inputPath":"isString.default(__)","inputFile":"isString.default(__)","outputFile":"isString.default(__)","useRegExp":"toBoolean.isBoolean.default(false)","flagsRegExp":"isString.default(\"g\")","logJob":"default(__)"}},"exec":"var b=isMap(args.__key)?args.__key:$path(\"args\"==args.__key?args:$get(args.__key),args.__path);_$(b,\"__key data\").isMap().$_();if(isUnDef(args.inputKey)&&isUnDef(args.inputFile))throw\"Need args inputKey or inputFile\";args.__op=\"read\";isDef(args.logJob)&&$job(args.logJob,args);var a=isDef(args.inputKey)?$path(\"args\"==args.inputKey?args:$get(args.inputKey),args.inputPath):io.readFileString(args.inputFile);Object.keys(b).forEach(function(c){a=a.replace(new RegExp(args.useRegExp?c:c.replace(/[.*+?^${}()|[\\]\\\\]/g,\n\"\\\\$&\"),args.useRegExp?args.flagsRegExp:\"g\"),b[c])});args.__op=\"write\";isDef(args.logJob)&&$job(args.logJob,args);isDef(args.outputFile)?io.writeFileString(args.outputFile,a):args.output=a"},{"name":"ojob channel","typeArgs":{"shortcut":{"name":"ch","keyArg":"__name","args":{"op":"__op","key":"__key","kpath":"__kpath","k":"key","ks":"keys","v":"value","vs":"values","vpath":"__vpath","extra":"extra"}}},"help":{"text":"Provides a set of operations over an OpenAF channel","expects":[{"name":"__name","desc":"The name of the OpenAF channel to use","required":true},{"name":"__op","desc":"The operation to perform (e.g. setall, set, get, unset, unsetall, getkeys, getall and size)","required":true},{"name":"__key","desc":"The key from where to retrieve the operation arguments (args to retrive from arguments)"},{"name":"__kpath","desc":"If defined, the path over the values retrieved from __key where the key or keys of the operation are defined"},{"name":"key","desc":"If defined, the key to use with the operations set, get and unset"},{"name":"keys","desc":"If defined, the set of fields to use with the operations setall and unsetall"},{"name":"value","desc":"If defined, the value to use with the operations set, get and unset"},{"name":"values","desc":"If defined, an array of values to use with the operations setall and unsetall"},{"name":"__vpath","desc":"If defined, the path over the values retrieved from __key where the value or values of the operation are defined"},{"name":"extra","desc":"If defined, will provide an extra argument (usually a map), depending on channel type, for the getall and getkeys operations."}],"returns":[{"name":"_list","desc":"If __key == 'args' will return the results of getall and getkeys"},{"name":"_map","desc":"If __key == 'args' will return the results of get"},{"name":"size","desc":"If __key == 'args' will return the size of the channel"}]},"check":{"in":{"__name":"isString","__op":"isString","key":"default(__)","keys":"default(__)","value":"default(__)","values":"default(__)","__kpath":"isString.default(__)","__vpath":"isString.default(__)","extra":"default(__)","__key":"default(\"res\")"}},"exec":"var a=function(){var b={k:__,v:__};isDef(args.key)&&(b.k=args.key);isDef(args.keys)&&(b.k=args.keys);isDef(args.value)&&(b.v=args.value);isDef(args.values)&&(b.v=args.values);\"args\"==args.__key?(isDef(args.__kpath)&&(b.k=$path(args,args.__kpath)),isDef(args.__vpath)&&(b.v=$path(args,args.__vpath))):(isDef(args.__kpath)&&(b.k=$path($get(args.__key),args.__kpath)),isDef(args.__vpath)&&(b.v=$path($get(args.__key),args.__vpath)));return b};switch(args.__op.toLowerCase()){case \"getall\":a=$ch(args.__name).getAll(args.extra);\nisUnDef(a)&&(a=[]);\"args\"!=args.__key?$set(args.__key,a):args._list=a;break;case \"setall\":a=a();$ch(args.__name).setAll(a.k,a.v);break;case \"set\":a=a();$ch(args.__name).set(a.k,a.v);break;case \"get\":a=a();a=$ch(args.__name).get(a.k);isUnDef(a)&&(a={});\"args\"!=args.__key?$set(args.__key,a):args._map=a;break;case \"unset\":a=a();$ch(args.__name).unset(a.k);break;case \"unsetall\":a=a();$ch(args.__name).unsetAll(a.k,a.v);break;case \"getkeys\":a=$ch(args.__name).getKeys(args.extra);isUnDef(a)&&(a=[]);\"args\"!=\nargs.__key?$set(args.__key,a):args._list=a;break;case \"size\":a=$ch(args.__name).size(),isUnDef(a)&&(a=-1),\"args\"!=args.__key?$set(args.__key,a):args.size=a}"},{"name":"ojob print","typeArgs":{"noLog":true,"shortcut":{"name":"print","keyArg":"msg","args":{"key":"__key","path":"__path","level":"level"}}},"help":{"text":"Prints a message line given an OpenAF template","expects":[{"name":"__key","desc":"Map key to retrieve ('args' for arguments)"},{"name":"__path","desc":"The path to consider from the __key"},{"name":"msg","desc":"The message template to use","required":true},{"name":"level","desc":"The level of the message (info (default) or error)"}]},"check":{"in":{"__key":"isString.default(\"res\")","__path":"isString.default(\"@\")","msg":"isString","level":"isString.oneOf([\"info\",\"error\"]).default(\"info\")"}},"exec":"var a=\"args\"==args.__key?$path(args,args.__path):$path($get(args.__key),args.__path);switch(args.level){case \"error\":tprintErr(args.msg,a);break;case \"info\":tprint(args.msg,a)}"},{"name":"ojob print md","typeArgs":{"noLog":true,"shortcut":{"name":"printmd","keyArg":"__text","args":{"outputMD":"__outputMD"}}},"help":{"text":"Parses an input text as simple ascii markdown","expects":[{"name":"__text","desc":"The text template to parse."},{"name":"__outputMD","desc":"A boolean flag that if true will no parse the input text"}]},"check":{"in":{"__text":"isString","__outputMD":"toBoolean.isBoolean.default(false)"}},"exec":"var a=clone(args);delete a.__text;args.__outputMD?printnl($t(args.__text,a)):printnl(ow.format.withMD($t(args.__text,a)));Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob log","typeArgs":{"noLog":true,"shortcut":{"name":"log","keyArg":"msg","args":{"key":"__key","path":"__path","level":"level","options":"options"}}},"help":{"text":"Logs a message line given an OpenAF template","expects":[{"name":"__key","desc":"Map key to retrieve ('args' for arguments)"},{"name":"__path","desc":"The path to consider from the __key"},{"name":"msg","desc":"The message template to use","required":true},{"name":"level","desc":"The level of the message (info (default), warn or error)"},{"name":"options","desc":"Extra options to provide to the tlog* functions. See more in the help of tlog, tlogErr and tlogWarn."}]},"check":{"in":{"__key":"isString.default(\"res\")","__path":"isString.default(\"@\")","msg":"isString","level":"isString.oneOf([\"info\",\"warn\",\"error\"]).default(\"info\")","options":"isMap.default({})"}},"exec":"var a=\"args\"==args.__key?$path(args,args.__path):$path($get(args.__key),args.__path);switch(args.level){case \"warn\":tlogWarn(args.msg,a,args.options);break;case \"error\":tlogErr(args.msg,a,args.options);break;case \"info\":tlog(args.msg,a,args.options)}"},{"name":"ojob function","typeArgs":{"noLog":true,"shortcut":{"name":"fn","keyArg":"__fn","args":{"key":"__key","path":"__path","fnPath":"__fnPath"}}},"help":{"text":"Executes the provided function mapping any args to the function arguments using the odoc help available for the provided function.\nNote: accessing odoc might be slow on a first execution.\n","expects":[{"name":"__key","desc":"The key string to retrieve previous results (defaults to 'res')","required":true},{"name":"__fn","desc":"The function to execute"},{"name":"__path","desc":"If defined the args path for the function arguments to consider"},{"name":"__fnPath","desc":"If defined the args path where to set the function result"}]},"check":{"in":{"__fn":"isString","__key":"isString.default(\"res\")"}},"exec":"0>args.__fn.indexOf(\".\")&&(args.__fn=\"global.\"+args.__fn);var a=$fnM(args.__fn,isDef(args.__path)?$path(args,args.__path):args);isString(args.__fnPath)&&(a=$$({}).set(args.__fnPath,a));isString(args.__key)?$set(args.__key,a):args=merge(args,a);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob output","typeArgs":{"noLog":true,"shortcut":{"name":"output","keyArg":"__key","args":{"path":"__path","format":"__format","title":"__title","internal":"__internal","query":"__query","csv":"__csv","function":"__function"}}},"help":{"text":"Prints the current arguments to the console.","expects":[{"name":"__key","desc":"The key string to retrieve previous results (defaults to 'res'). If \"args\" will retrieve from current args."},{"name":"__path","desc":"A path string to a map/array over the results set on key."},{"name":"__format","desc":"The output format (e.g. see ow.oJob.output help)"},{"name":"__title","desc":"Encapsulates the output map/array with a title key."},{"name":"__internal","desc":"Boolean value that if true it will display the internal oJob entries on the arguments (default false)"},{"name":"__function","desc":"One of the OpenAF's print or log functions available"}]},"exec":"isUnDef(args.__key)&&isDef(args.key)&&(args.__key=args.key);isUnDef(args.__path)&&isDef(args.path)&&(args.__path=args.path);isUnDef(args.__format)&&isDef(args.format)&&(args.__format=args.format);isUnDef(args.__title)&&isDef(args.title)&&(args.__title=args.title);isUnDef(args.__internal)&&isDef(args.internal)&&(args.__internal=args.internal);if(isString(args.__function))if(0<=args.__function.indexOf(\"print\")||0<=args.__function.indexOf(\"log\")){if(!(0<=af.fromJavaArray(af.getScopeIds()).map(function(b){return String(b)}).indexOf(args.__function)))throw\"__function '\"+\nargs.__function+\"' not found.\";args.__function=global[args.__function]}else throw\"__function needs to be a 'print' or 'log' function\";else args.__function=__;args.__key=_$(args.__key,\"key\").isString().default(\"res\");\"\"==args.__key&&(args.__key=\"res\");var a=\"args\"==args.__key?args:$get(args.__key);isUnDef(a)&&(a=args);!isDef(a)||isNull(a)||toBoolean(args.__internal)||(delete a.objId,delete a.execid,delete a.id);isDef(args.format)&&(args.__format=args.format,delete args.format);isDef(args.__path)&&\n(a=$path(a,args.__path),delete args.__path);isMap(a)&&isDef(a._list)&&(a=a._list);isMap(a)&&isDef(a._map)&&(a=a._map);if(isDef(args.__title)){var c={};c[args.__title]=a;ow.oJob.output(c,args,args.__function)}else ow.oJob.output(a,args,args.__function);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob final report","to":"ojob report","type":"shutdown","help":{"text":"Outputs a jobs report (e.g. job name, status, number of executions, total time, avg time and last execution) upon ojob termination","expects":[{"name":"__format","desc":"Can be json, yaml, table (default) or any other ow.oJob.output format"}]}},{"name":"ojob final deps report","to":"ojob deps report","type":"shutdown","help":{"text":"Outputs a tree list for each defined job (excluding \"ojob *\") and a comma delimited list of dependencies with a status flag"}},{"name":"ojob deps report","help":{"text":"Outputs a tree list for each defined job (excluding \"ojob *\") and a comma delimited list of dependencies with a status flag"},"exec":"var b={};$from($ch(\"oJob::log\").getAll()).notStarts(\"name\",\"ojob \").select(function(a){b[a.name]=a.start?a.success?ansiColor(\"GREEN\",\"\\u2713\"):a.deps?a.error?ansiColor(\"RED\",\"\\u2715\"):ansiColor(\"BLUE\",\"\\u25b7\"):ansiColor(\"RED\",\"\\u2715\"):ansiColor(\"YELLOW\",\"\\u23f8\")});var c={};$from($ch(\"oJob::jobs\").getAll()).notStarts(\"name\",\"ojob \").select(function(a){c[a.name]=a.deps.map(function(d){return b[d]+\" \"+d}).join(\", \")});ow.oJob.output(c,{__format:\"tree\"})"},{"name":"ojob report","help":{"text":"Outputs a jobs report (e.g. job name, status, number of executions, total time, avg time and last execution)","expects":[{"name":"__format","desc":"Can be json, yaml, table (default) or any other ow.oJob.output format"}]},"exec":"ow.loadFormat();print(\"\\n\");var b=$ch(\"oJob::log\").getAll(),c=$from(b).notEquals(\"name\",\"ojob report\").notEquals(\"name\",\"ojob final report\").select(function(a){return{\"Job name\":a.name,Status:a.start?a.success?\"OK\":a.deps?a.error?\"NOT OK!\":\"executing\":\"failed deps\":\"not started\",\"# execs\":a.count,\"Total time\":ow.format.elapsedTime4ms(a.totalTime,{abrev:!0}),\"Avg time\":ow.format.elapsedTime4ms(a.avgTime,{abrev:!0}),\"Last exec\":0args.validStates.indexOf(args.state)&&(isDef(args.default)?args.state=args.default:args.state=__);isString(args.state)&&isDef(ow.oJob.setState)&&ow.oJob.setState(args.state)"},{"name":"ojob todo","typeArgs":{"noLog":true,"shortcut":{"name":"todo","keyArg":"todo","args":{"isolateArgs":"isolateArgs","isolateJob":"isolateJob","templateArgs":"templateArgs","shareArgs":"shareArgs","debug":"__debug"}}},"help":{"text":"Executes an ojob sub-todo.\nNOTE: doesn't perform any checks for recursive behaviour!","expects":[{"name":"todo","desc":"A string or array of todo' maps"},{"name":"todo[].name","desc":"Name of the job to execute"},{"name":"todo[].args","desc":"Arguments to merge (if isolateArgs is not true) with the main job arguments"},{"name":"todo[].isolateArgs","desc":"Boolean to indicate, for a specific todo, that args should be isolated from all others"},{"name":"todo[].isolateJob","desc":"Boolean to indicate, for a specific todo, that the job should run in a different scope (e.g. deps will not work)"},{"name":"todo[].templateArgs","desc":"Boolean to indicate, for a specific todo, to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"isolateArgs","desc":"Boolean, false by default, to indicate that args should be isolated from all others"},{"name":"isolateJob","desc":"Boolean, false by default, to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean, true by default, to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"shareArgs","desc":"Boolean, false by default, to indicate that args should be shared between all todo's jobs sequentially."},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"check":{"in":{"isolateArgs":"toBoolean.isBoolean.default(false)","isolateJob":"toBoolean.isBoolean.default(false)","templateArgs":"toBoolean.isBoolean.default(true)","shareArgs":"toBoolean.isBoolean.default(false)","__debug":"toBoolean.isBoolean.default(false)"}},"exec":"if(!isString(args.todo)&&!isArray(args.todo))throw\"todo needs to be a string or an array\";isString(args.todo)&&(args.todo=[args.todo]);var a=clone(args);delete a.todo;delete a.isolateArgs;delete a.templateArgs;delete a.shareArgs;delete a.__debug;args.todo.forEach(function(b){if(!isMap(b)&&!isString(b))throw\"todo entry needs to be a map or a string (\"+af.toSLON(b)+\")\";b=$job(\"ojob run\",{job:b,id:ow.oJob.__id,isolateArgs:args.isolateArgs,isolateJob:args.isolateJob,templateArgs:args.templateArgs,\n__debug:args.__debug,args:a});args.shareArgs&&(a=merge(a,b))})"},{"name":"ojob run","typeArgs":{"noLog":true},"check":{"in":{"job":"default(__)","id":"isString.default(ow.oJob.__id)","isolateArgs":"toBoolean.isBoolean.default(false)","isolateJob":"toBoolean.isBoolean.default(false)","templateArgs":"toBoolean.isBoolean.default(true)","__debug":"toBoolean.isBoolean.default(false)"}},"help":{"text":"Executes an ojob but alternatively use 'ojob todo' or $job for most functionality.","expects":[{"name":"job","desc":"Name of the job to execute"},{"name":"id","desc":"The oJob id to execute (leave undefined to default to the current one)"},{"name":"args","desc":"The args to consider on execution."},{"name":"isolateArgs","desc":"Boolean to indicate that args should be isolated."},{"name":"isolateJob","desc":"Boolean to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"exec":"if(!isString(args.job)&&!isMap(args.job))throw\"job needs to be either a string or job map\";isString(args.job)&&(args.job={name:args.job});args.job.templateArgs=_$(args.job.templateArgs,\"templateArgs \"+args.job.name).isBoolean().default(args.templateArgs);args.job.isolateArgs=_$(args.job.isolateArgs,\"isolateArgs \"+args.job.name).isBoolean().default(args.isolateArgs);args.job.isolateJob=_$(args.job.isolateJob,\"isolateJob \"+args.job.name).isBoolean().default(args.isolateJob);args.job.templateArgs&&\nisDef(args.args)&&args.job.templateArgs&&isDef(args.job.args)&&(isString(args.job.args)&&(args.job.args=ow.oJob.__processArgs(args.job.args)),traverse(args.job.args,function(c,b,e,d){isString(b)&&(d[c]=templify(b,args))}));args.job=ow.oJob.parseTodo(args.job);var a={name:args.job.name,args:args.job.isolateArgs?args.job.args:merge(args.args,args.job.args),id:args.job.isolateJob?__:args.id};args.__debug&&cprint(ow.format.withSideLine(printTreeOrS(a,__,{bgcolor:\"BG(235)\"}),__,\"FG(240)\",\"BG(235)\",ow.format.withSideLineThemes().openBottomCurvedRect));\nargs=merge(args,$job(a.name,a.args,a.id))"},{"name":"ojob run file","typeArgs":{"noLog":true,"shortcut":{"name":"runfile","keyArg":"__job","args":{"args":"__args","out":"__out","key":"__key","inKey":"__inKey","usePM":"__usePM","inPM":"__inPM","templateArgs":"__templateArgs","debug":"__debug"}}},"help":{"text":"Executes an external YAML/JSON ojob file or a remote URL with the provided args.","expects":[{"name":"__job","desc":"The YAML/JSON ojob file or remote URL to run"},{"name":"__args","desc":"The args to provide to the external ojob file/url"},{"name":"__out","desc":"The path on args to set the map key/path contents"},{"name":"__key","desc":"If __out is not defined will set the content into the provided key"},{"name":"__inKey","desc":"If defined, args will be merged with the content from the provided key"},{"name":"__usePM","desc":"Output to __pm"},{"name":"__inPM","desc":"Input from provided key to __pm"},{"name":"__templateArgs","desc":"Boolean to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"__debug","desc":"Boolean to indicate that the job execution parameters should be printed before executing"}]},"check":{"in":{"__job":"isString","__args":"isMap.default({})","__out":"isString.default(__)","__key":"isString.default(\"res\")","__inKey":"isString.default(__)","__usePM":"toBoolean.isBoolean.default(false)","__inPM":"isString.default(__)","__templateArgs":"toBoolean.isBoolean.default(false)","__debug":"toBoolean.isBoolean.default(false)"}},"exec":"var c=\"args\"==args.__key?\"r\"+nowNano():args.__key;args.__templateArgs&&isDef(args.__args)&&traverse(args.__args,function(b,d,g,f){isString(d)&&(f[b]=templify(d,args))});if(args.__usePM){var a={__format:\"pm\"};args.__key=__;args.__usePM=__}else a={__format:\"key\",__key:c};if(isDef(args.__inKey)){var e=$get(args.__inKey);a=merge(isDef(e)?merge(args.__args,e):args.__args,a)}else a=merge(args.__args,a);isDef(args.__inPM)&&ow.oJob.output($get(args.__inPM),{__format:\"pm\"});args.__debug&&cprint(ow.format.withSideLine(printTreeOrS(a,\n__,{bgcolor:\"BG(235)\"}),__,\"FG(235)\",\"BG(235)\",ow.format.withSideLineThemes().openBottomCurvedRect));ow.oJob.runFile(args.__job,a,c,!0,{shareArgs:!1});if(\"args\"==args.__key||\"res\"==args.__key)a=$get(c),isDef(a)&&(delete a.__format,delete a.__key,args=merge(args,a),\"args\"==args.__key&&$unset(c));Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob parallel","typeArgs":{"noLog":true,"shortcut":{"name":"parallel","keyArg":"todo"}},"help":{"text":"Executes an ojob sub-todo in parallel.\nNOTE: doesn't perform any checks for recursive behaviour!","expects":[{"name":"todo","desc":"A string or array of todo' maps"},{"name":"todo[].name","desc":"Name of the job to execute"},{"name":"todo[].args","desc":"Arguments to merge (if isolateArgs is not true) with the main job arguments"},{"name":"todo[].isolateArgs","desc":"Boolean to indicate, for a specific todo, that args should be isolated from all others"},{"name":"todo[].isolateJob","desc":"Boolean to indicate, for a specific todo, that the job should run in a different scope (e.g. deps will not work)"},{"name":"todo[].templateArgs","desc":"Boolean to indicate, for a specific todo, to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"isolateArgs","desc":"Boolean, false by default, to indicate that args should be isolated from all others"},{"name":"isolateJob","desc":"Boolean, false by default, to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean, true by default, to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"shareArgs","desc":"Boolean, false by default, to indicate that args should be shared between all todo's jobs sequentially."},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"check":{"in":{"isolateArgs":"toBoolean.isBoolean.default(false)","isolateJob":"toBoolean.isBoolean.default(false)","templateArgs":"toBoolean.isBoolean.default(true)","shareArgs":"toBoolean.isBoolean.default(false)","__debug":"toBoolean.isBoolean.default(false)"}},"exec":"if(!isString(args.todo)&&!isArray(args.todo))throw\"todo needs to be a string or an array\";isString(args.todo)&&(args.todo=[args.todo]);var a=clone(args),c=[];delete a.todo;delete a.isolateArgs;delete a.templateArgs;delete a.shareArgs;delete a.__debug;args.todo.forEach(function(b){if(!isMap(b)&&!isString(b))throw\"todo entry needs to be a map or a string (\"+af.toSLON(b)+\")\";c.push($do(function(){return $job(\"ojob run\",{job:b,id:ow.oJob.__id,isolateArgs:args.isolateArgs,isolateJob:args.isolateJob,\ntemplateArgs:args.templateArgs,__debug:args.__debug,args:a})}))});$doWait($doAll(c))"},{"name":"ojob wait","typeArgs":{"noLog":true,"shortcut":{"name":"wait","keyArg":"time"}},"help":{"text":"Waits for a specific amount of time","expects":[{"name":"time","desc":"The amount of time, in ms, to pause execution"}]},"check":{"in":{"time":"toNumber.isNumber"}},"exec":"sleep(args.time,!0)"},{"name":"ojob exit","typeArgs":{"noLog":true,"shortcut":{"name":"fail","keyArg":"code","args":{"force":"force"}}},"help":{"text":"Ends all processing with an exit code","expects":[{"name":"code","desc":"The exit code number to use"},{"name":"force","desc":"A boolean indicating if instead of exit the processing should halt"}]},"check":{"in":{"code":"toNumber.isNumber.default(0)","force":"toBoolean.isBoolean.default(false)"}},"exec":"exit(args.code,args.force)"},{"name":"ojob convert","typeArgs":{"noLog":false,"shortcut":{"name":"convert","keyArg":"__inKey","args":{"inPath":"__inPath","inFormat":"__inFormat","outPath":"__outPath","outKey":"__outKey"}}},"check":{"in":{"__inPath":"isString.default(\"\")","__inKey":"isString.default(\"res\")","__inFormat":"isString.oneOf(['yaml','json','xml','ndjson','slon'])","__outPath":"isString.default(__)","__outKey":"isString.default(__)"}},"help":{"text":"Converts string content into an internal object (map/array)","expects":[{"name":"__inKey","desc":"Where to find the input contents to convert (if 'args' will default to the current args)"},{"name":"__inPath","desc":"The path on the input contents for the string to convert"},{"name":"__inFormat","desc":"The format of the input contents (yaml, json, xml, ndjson, slon)"},{"name":"__outKey","desc":"Where the converted output object should be placed (if 'args' with default to the current args)"},{"name":"__outPath","desc":"The path on the output contents to store the converted object"}]},"exec":"var c=\"args\"!=args.__inKey?String($$(args).get(args.__inPath)):String($$($get(args.__inKey)).get(args.__inPath));isUnDef(args.__outKey)&&(args.__outKey=args.__inKey);isUnDef(args.__outPath)&&(args.__outPath=args.__inPath);switch(args.__inFormat){case \"yaml\":_$(c,\"yaml input\").isString().$_();var a=af.fromYAML(c);break;case \"json\":a=jsonParse(c,!0);break;case \"ndjson\":a=c.split(\"\\n\").map(function(b){return jsonParse(b,!0)}).filter(function(b){return isDef(b)&&!isNull(b)});break;case \"xml\":a=\naf.fromXML2Obj(a);break;case \"slon\":a=af.fromSLON(a);break;default:throw\"No inFormat provided.\";}\"args\"!=args.__outKey?$$(args).set(args.__outPath,a):($get(args.outKey),$$(o).set(args.outPath,a),$set(args.outKey,o));Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"}]} \ No newline at end of file diff --git a/ojob.saved.json b/ojob.saved.json index 8bc9ea87..9d595d4d 100644 --- a/ojob.saved.json +++ b/ojob.saved.json @@ -1 +1 @@ -[{"name":"ojob deps report","type":"simple","args":{},"deps":[],"help":{"text":"Outputs a tree list for each defined job (excluding \"ojob *\") and a comma delimited list of dependencies with a status flag"},"each":[],"exec":"\n\nvar b={};$from($ch(\"oJob::log\").getAll()).notStarts(\"name\",\"ojob \").select(function(a){b[a.name]=a.start?a.success?ansiColor(\"GREEN\",\"\\u2713\"):a.deps?a.error?ansiColor(\"RED\",\"\\u2715\"):ansiColor(\"BLUE\",\"\\u25b7\"):ansiColor(\"RED\",\"\\u2715\"):ansiColor(\"YELLOW\",\"\\u23f8\")});var c={};$from($ch(\"oJob::jobs\").getAll()).notStarts(\"name\",\"ojob \").select(function(a){c[a.name]=a.deps.map(function(d){return b[d]+\" \"+d}).join(\", \")});ow.oJob.output(c,{__format:\"tree\"})"},{"name":"ojob job report","type":"simple","args":{},"deps":[],"help":{"text":"Outputs a job jobs report (e.g. job name, action and plan)","expects":[{"name":"__format","desc":"Can be json, yaml, table (default) or any other ow.oJob.output format"}]},"each":[],"exec":"\n\now.oJob.output($ch(\"_ojob_plan\").getAll(),{__format:_$(args.__format).default(\"table\")})"},{"name":"ojob job","type":"simple","typeArgs":{"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Provides a way to organize idempotent jobs. One or more \"checks\" jobs will be called to determine an args._action.\nInitially the args._action is set to \"none\". If the \"checks\" jobs determine an action it will call the corresponding\njobs on \"actions\" jobs. If \"_go=true\" is not provided, instead of running, it will only return a plan of actions. \nFor example:\n\n - name: Write Hello World\n to : ojob job\n args:\n _checks : Check Hello World\n _actions:\n create : Create Hello World\n overwrite: Overwrite Hello World\n delete : Delete Hello World\n","expects":[{"name":"_checks","desc":"A list of one or more jobs to be called to perform checks to determine an args._action"},{"name":"_actions","desc":"A map of possible values of args._action whose values are one or more jobs to execute"},{"name":"_go","desc":"A boolean value (defaults to false) that controls if the _actions jobs are called (when true) or not"}]},"each":[],"exec":"\n$$(args).set(\"_go\", _$($$(args).get(\"_go\"), \"Job (ojob job), args [_go]\").toBoolean().isBoolean().default(false))\n\nisString(args._checks)&&(args._checks=[args._checks]);isString(args._actions)&&(args._actions={none:args._actions});var c=function(a){a=clone(a);delete a._checks;delete a._actions;return a};args._action=\"none\";args._checks.forEach(function(a){isString(a)?(a=$job(a,c(args)),isMap(a)&&isString(a._action)&&(args._action=a._action)):logErr(\"oJob Job 'checks' must be job names\")});$ch(\"_ojob_plan\").create();$ch(\"_ojob_plan\").get({name:job.name});var d=[];if(isDef(args._actions[args._action])){var b;\nisArray(args._actions[args._action])&&(b=args._actions[args._action]);isString(args._actions[args._action])&&(b=[args._actions[args._action]]);b.forEach(function(a){args._go?$job(a,c(args)):d.push(a)})}$ch(\"_ojob_plan\").set({name:job.name},{name:job.name,action:args._action,\"go?\":args._go,plan:d})"},{"name":"ojob report","type":"simple","args":{},"deps":[],"help":{"text":"Outputs a jobs report (e.g. job name, status, number of executions, total time, avg time and last execution)","expects":[{"name":"__format","desc":"Can be json, yaml, table (default) or any other ow.oJob.output format"}]},"each":[],"exec":"\n\now.loadFormat();print(\"\\n\");var b=$ch(\"oJob::log\").getAll(),c=$from(b).notEquals(\"name\",\"ojob report\").notEquals(\"name\",\"ojob final report\").select(function(a){return{\"Job name\":a.name,Status:a.start?a.success?\"OK\":a.deps?a.error?\"NOT OK!\":\"executing\":\"failed deps\":\"not started\",\"# execs\":a.count,\"Total time\":ow.format.elapsedTime4ms(a.totalTime,{abrev:!0}),\"Avg time\":ow.format.elapsedTime4ms(a.avgTime,{abrev:!0}),\"Last exec\":0args.__fn.indexOf(\".\")&&(args.__fn=\"global.\"+args.__fn);var a=$fnM(args.__fn,isDef(args.__path)?$path(args,args.__path):args);isString(args.__fnPath)&&(a=$$({}).set(args.__fnPath,a));isString(args.__key)?$set(args.__key,a):args=merge(args,a);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob output","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(output","keyArg":"__key","args":{"path":"__path","format":"__format","title":"__title","internal":"__internal","query":"__query","csv":"__csv","function":"__function"},"job":"ojob output","nolog":false,"map":true,"attrs":{"(output":"__key","((path":"__path","((format":"__format","((title":"__title","((internal":"__internal","((query":"__query","((csv":"__csv","((function":"__function"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Prints the current arguments to the console.","expects":[{"name":"__key","desc":"The key string to retrieve previous results (defaults to 'res'). If \"args\" will retrieve from current args."},{"name":"__path","desc":"A path string to a map/array over the results set on key."},{"name":"__format","desc":"The output format (e.g. see ow.oJob.output help)"},{"name":"__title","desc":"Encapsulates the output map/array with a title key."},{"name":"__internal","desc":"Boolean value that if true it will display the internal oJob entries on the arguments (default false)"},{"name":"__function","desc":"One of the OpenAF's print or log functions available"}]},"each":[],"exec":"\n\nisUnDef(args.__key)&&isDef(args.key)&&(args.__key=args.key);isUnDef(args.__path)&&isDef(args.path)&&(args.__path=args.path);isUnDef(args.__format)&&isDef(args.format)&&(args.__format=args.format);isUnDef(args.__title)&&isDef(args.title)&&(args.__title=args.title);isUnDef(args.__internal)&&isDef(args.internal)&&(args.__internal=args.internal);if(isString(args.__function))if(0<=args.__function.indexOf(\"print\")||0<=args.__function.indexOf(\"log\")){if(!(0<=af.fromJavaArray(af.getScopeIds()).map(function(b){return String(b)}).indexOf(args.__function)))throw\"__function '\"+\nargs.__function+\"' not found.\";args.__function=global[args.__function]}else throw\"__function needs to be a 'print' or 'log' function\";else args.__function=__;args.__key=_$(args.__key,\"key\").isString().default(\"res\");\"\"==args.__key&&(args.__key=\"res\");var a=\"args\"==args.__key?args:$get(args.__key);isUnDef(a)&&(a=args);!isDef(a)||isNull(a)||toBoolean(args.__internal)||(delete a.objId,delete a.execid,delete a.id);isDef(args.format)&&(args.__format=args.format,delete args.format);isDef(args.__path)&&\n(a=$path(a,args.__path),delete args.__path);isMap(a)&&isDef(a._list)&&(a=a._list);isMap(a)&&isDef(a._map)&&(a=a._map);if(isDef(args.__title)){var c={};c[args.__title]=a;ow.oJob.output(c,args,args.__function)}else ow.oJob.output(a,args,args.__function);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob final report","type":"shutdown","args":{},"deps":[],"help":{"text":"Outputs a jobs report (e.g. job name, status, number of executions, total time, avg time and last execution) upon ojob termination","expects":[{"name":"__format","desc":"Can be json, yaml, table (default) or any other ow.oJob.output format"}]},"to":"ojob report","each":"\n","exec":"\n\nargs = ow.oJob.__processArgs(args, {})\n\n\n\n\now.loadFormat();print(\"\\n\");var b=$ch(\"oJob::log\").getAll(),c=$from(b).notEquals(\"name\",\"ojob report\").notEquals(\"name\",\"ojob final report\").select(function(a){return{\"Job name\":a.name,Status:a.start?a.success?\"OK\":a.deps?a.error?\"NOT OK!\":\"executing\":\"failed deps\":\"not started\",\"# execs\":a.count,\"Total time\":ow.format.elapsedTime4ms(a.totalTime,{abrev:!0}),\"Avg time\":ow.format.elapsedTime4ms(a.avgTime,{abrev:!0}),\"Last exec\":0args.validStates.indexOf(args.state)&&(isDef(args.default)?args.state=args.default:args.state=__);isString(args.state)&&isDef(ow.oJob.setState)&&ow.oJob.setState(args.state)"},{"name":"ojob todo","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(todo","keyArg":"todo","args":{"isolateArgs":"isolateArgs","isolateJob":"isolateJob","templateArgs":"templateArgs","shareArgs":"shareArgs","debug":"__debug"},"job":"ojob todo","nolog":false,"map":true,"attrs":{"(todo":"todo","((isolateArgs":"isolateArgs","((isolateJob":"isolateJob","((templateArgs":"templateArgs","((shareArgs":"shareArgs","((debug":"__debug"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Executes an ojob sub-todo.\nNOTE: doesn't perform any checks for recursive behaviour!","expects":[{"name":"todo","desc":"A string or array of todo' maps"},{"name":"todo[].name","desc":"Name of the job to execute"},{"name":"todo[].args","desc":"Arguments to merge (if isolateArgs is not true) with the main job arguments"},{"name":"todo[].isolateArgs","desc":"Boolean to indicate, for a specific todo, that args should be isolated from all others"},{"name":"todo[].isolateJob","desc":"Boolean to indicate, for a specific todo, that the job should run in a different scope (e.g. deps will not work)"},{"name":"todo[].templateArgs","desc":"Boolean to indicate, for a specific todo, to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"isolateArgs","desc":"Boolean, false by default, to indicate that args should be isolated from all others"},{"name":"isolateJob","desc":"Boolean, false by default, to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean, true by default, to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"shareArgs","desc":"Boolean, false by default, to indicate that args should be shared between all todo's jobs sequentially."},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"each":[],"exec":"\n$$(args).set(\"isolateArgs\", _$($$(args).get(\"isolateArgs\"), \"Job (ojob todo), args [isolateArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"isolateJob\", _$($$(args).get(\"isolateJob\"), \"Job (ojob todo), args [isolateJob]\").toBoolean().isBoolean().default(false));$$(args).set(\"templateArgs\", _$($$(args).get(\"templateArgs\"), \"Job (ojob todo), args [templateArgs]\").toBoolean().isBoolean().default(true));$$(args).set(\"shareArgs\", _$($$(args).get(\"shareArgs\"), \"Job (ojob todo), args [shareArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"__debug\", _$($$(args).get(\"__debug\"), \"Job (ojob todo), args [__debug]\").toBoolean().isBoolean().default(false))\n\nif(!isString(args.todo)&&!isArray(args.todo))throw\"todo needs to be a string or an array\";isString(args.todo)&&(args.todo=[args.todo]);var a=clone(args);delete a.todo;delete a.isolateArgs;delete a.templateArgs;delete a.shareArgs;delete a.__debug;args.todo.forEach(function(b){if(!isMap(b)&&!isString(b))throw\"todo entry needs to be a map or a string (\"+af.toSLON(b)+\")\";b=$job(\"ojob run\",{job:b,id:ow.oJob.__id,isolateArgs:args.isolateArgs,isolateJob:args.isolateJob,templateArgs:args.templateArgs,\n__debug:args.__debug,args:a});args.shareArgs&&(a=merge(a,b))})"},{"name":"ojob run","type":"simple","typeArgs":{"noLog":true,"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Executes an ojob but alternatively use 'ojob todo' or $job for most functionality.","expects":[{"name":"job","desc":"Name of the job to execute"},{"name":"id","desc":"The oJob id to execute (leave undefined to default to the current one)"},{"name":"args","desc":"The args to consider on execution."},{"name":"isolateArgs","desc":"Boolean to indicate that args should be isolated."},{"name":"isolateJob","desc":"Boolean to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"each":[],"exec":"\n$$(args).set(\"job\", _$($$(args).get(\"job\"), \"Job (ojob run), args [job]\").default(__));$$(args).set(\"id\", _$($$(args).get(\"id\"), \"Job (ojob run), args [id]\").isString().default(ow.oJob.__id));$$(args).set(\"isolateArgs\", _$($$(args).get(\"isolateArgs\"), \"Job (ojob run), args [isolateArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"isolateJob\", _$($$(args).get(\"isolateJob\"), \"Job (ojob run), args [isolateJob]\").toBoolean().isBoolean().default(false));$$(args).set(\"templateArgs\", _$($$(args).get(\"templateArgs\"), \"Job (ojob run), args [templateArgs]\").toBoolean().isBoolean().default(true));$$(args).set(\"__debug\", _$($$(args).get(\"__debug\"), \"Job (ojob run), args [__debug]\").toBoolean().isBoolean().default(false))\n\nif(!isString(args.job)&&!isMap(args.job))throw\"job needs to be either a string or job map\";isString(args.job)&&(args.job={name:args.job});args.job.templateArgs=_$(args.job.templateArgs,\"templateArgs \"+args.job.name).isBoolean().default(args.templateArgs);args.job.isolateArgs=_$(args.job.isolateArgs,\"isolateArgs \"+args.job.name).isBoolean().default(args.isolateArgs);args.job.isolateJob=_$(args.job.isolateJob,\"isolateJob \"+args.job.name).isBoolean().default(args.isolateJob);args.job.templateArgs&&\nisDef(args.args)&&args.job.templateArgs&&isDef(args.job.args)&&(isString(args.job.args)&&(args.job.args=ow.oJob.__processArgs(args.job.args)),traverse(args.job.args,function(c,b,e,d){isString(b)&&(d[c]=templify(b,args))}));args.job=ow.oJob.parseTodo(args.job);var a={name:args.job.name,args:args.job.isolateArgs?args.job.args:merge(args.args,args.job.args),id:args.job.isolateJob?__:args.id};args.__debug&&cprint(ow.format.withSideLine(printTreeOrS(a,__,{bgcolor:\"BG(235)\"}),__,\"FG(240)\",\"BG(235)\",ow.format.withSideLineThemes().openBottomCurvedRect));\nargs=merge(args,$job(a.name,a.args,a.id))"},{"name":"ojob run file","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(runfile","keyArg":"__job","args":{"args":"__args","out":"__out","key":"__key","inKey":"__inKey","usePM":"__usePM","inPM":"__inPM","templateArgs":"__templateArgs","debug":"__debug"},"job":"ojob run file","nolog":false,"map":true,"attrs":{"(runfile":"__job","((args":"__args","((out":"__out","((key":"__key","((inKey":"__inKey","((usePM":"__usePM","((inPM":"__inPM","((templateArgs":"__templateArgs","((debug":"__debug"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Executes an external YAML/JSON ojob file or a remote URL with the provided args.","expects":[{"name":"__job","desc":"The YAML/JSON ojob file or remote URL to run"},{"name":"__args","desc":"The args to provide to the external ojob file/url"},{"name":"__out","desc":"The path on args to set the map key/path contents"},{"name":"__key","desc":"If __out is not defined will set the content into the provided key"},{"name":"__inKey","desc":"If defined, args will be merged with the content from the provided key"},{"name":"__usePM","desc":"Output to __pm"},{"name":"__inPM","desc":"Input from provided key to __pm"},{"name":"__templateArgs","desc":"Boolean to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"__debug","desc":"Boolean to indicate that the job execution parameters should be printed before executing"}]},"each":[],"exec":"\n$$(args).set(\"__job\", _$($$(args).get(\"__job\"), \"Job (ojob run file), args [__job]\").isString().$_());$$(args).set(\"__args\", _$($$(args).get(\"__args\"), \"Job (ojob run file), args [__args]\").isMap().default({}));$$(args).set(\"__out\", _$($$(args).get(\"__out\"), \"Job (ojob run file), args [__out]\").isString().default(__));$$(args).set(\"__key\", _$($$(args).get(\"__key\"), \"Job (ojob run file), args [__key]\").isString().default(\"res\"));$$(args).set(\"__inKey\", _$($$(args).get(\"__inKey\"), \"Job (ojob run file), args [__inKey]\").isString().default(__));$$(args).set(\"__usePM\", _$($$(args).get(\"__usePM\"), \"Job (ojob run file), args [__usePM]\").toBoolean().isBoolean().default(false));$$(args).set(\"__inPM\", _$($$(args).get(\"__inPM\"), \"Job (ojob run file), args [__inPM]\").isString().default(__));$$(args).set(\"__templateArgs\", _$($$(args).get(\"__templateArgs\"), \"Job (ojob run file), args [__templateArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"__debug\", _$($$(args).get(\"__debug\"), \"Job (ojob run file), args [__debug]\").toBoolean().isBoolean().default(false))\n\nvar c=\"args\"==args.__key?\"r\"+nowNano():args.__key;args.__templateArgs&&isDef(args.__args)&&traverse(args.__args,function(b,d,g,f){isString(d)&&(f[b]=templify(d,args))});if(args.__usePM){var a={__format:\"pm\"};args.__key=__;args.__usePM=__}else a={__format:\"key\",__key:c};if(isDef(args.__inKey)){var e=$get(args.__inKey);a=merge(isDef(e)?merge(args.__args,e):args.__args,a)}else a=merge(args.__args,a);isDef(args.__inPM)&&ow.oJob.output($get(args.__inPM),{__format:\"pm\"});args.__debug&&cprint(ow.format.withSideLine(printTreeOrS(a,\n__,{bgcolor:\"BG(235)\"}),__,\"FG(235)\",\"BG(235)\",ow.format.withSideLineThemes().openBottomCurvedRect));ow.oJob.runFile(args.__job,a,c,!0,{shareArgs:!1});if(\"args\"==args.__key||\"res\"==args.__key)a=$get(c),isDef(a)&&(delete a.__format,delete a.__key,args=merge(args,a),\"args\"==args.__key&&$unset(c));Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob parallel","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(parallel","keyArg":"todo","job":"ojob parallel","nolog":false,"map":true,"attrs":{"(parallel":"todo"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Executes an ojob sub-todo in parallel.\nNOTE: doesn't perform any checks for recursive behaviour!","expects":[{"name":"todo","desc":"A string or array of todo' maps"},{"name":"todo[].name","desc":"Name of the job to execute"},{"name":"todo[].args","desc":"Arguments to merge (if isolateArgs is not true) with the main job arguments"},{"name":"todo[].isolateArgs","desc":"Boolean to indicate, for a specific todo, that args should be isolated from all others"},{"name":"todo[].isolateJob","desc":"Boolean to indicate, for a specific todo, that the job should run in a different scope (e.g. deps will not work)"},{"name":"todo[].templateArgs","desc":"Boolean to indicate, for a specific todo, to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"isolateArgs","desc":"Boolean, false by default, to indicate that args should be isolated from all others"},{"name":"isolateJob","desc":"Boolean, false by default, to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean, true by default, to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"shareArgs","desc":"Boolean, false by default, to indicate that args should be shared between all todo's jobs sequentially."},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"each":[],"exec":"\n$$(args).set(\"isolateArgs\", _$($$(args).get(\"isolateArgs\"), \"Job (ojob parallel), args [isolateArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"isolateJob\", _$($$(args).get(\"isolateJob\"), \"Job (ojob parallel), args [isolateJob]\").toBoolean().isBoolean().default(false));$$(args).set(\"templateArgs\", _$($$(args).get(\"templateArgs\"), \"Job (ojob parallel), args [templateArgs]\").toBoolean().isBoolean().default(true));$$(args).set(\"shareArgs\", _$($$(args).get(\"shareArgs\"), \"Job (ojob parallel), args [shareArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"__debug\", _$($$(args).get(\"__debug\"), \"Job (ojob parallel), args [__debug]\").toBoolean().isBoolean().default(false))\n\nif(!isString(args.todo)&&!isArray(args.todo))throw\"todo needs to be a string or an array\";isString(args.todo)&&(args.todo=[args.todo]);var a=clone(args),c=[];delete a.todo;delete a.isolateArgs;delete a.templateArgs;delete a.shareArgs;delete a.__debug;args.todo.forEach(function(b){if(!isMap(b)&&!isString(b))throw\"todo entry needs to be a map or a string (\"+af.toSLON(b)+\")\";c.push($do(function(){return $job(\"ojob run\",{job:b,id:ow.oJob.__id,isolateArgs:args.isolateArgs,isolateJob:args.isolateJob,\ntemplateArgs:args.templateArgs,__debug:args.__debug,args:a})}))});$doWait($doAll(c))"},{"name":"ojob wait","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(wait","keyArg":"time","job":"ojob wait","nolog":false,"map":true,"attrs":{"(wait":"time"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Waits for a specific amount of time","expects":[{"name":"time","desc":"The amount of time, in ms, to pause execution"}]},"each":[],"exec":"\n$$(args).set(\"time\", _$($$(args).get(\"time\"), \"Job (ojob wait), args [time]\").toNumber().isNumber().$_())\n\nsleep(args.time,!0)"},{"name":"ojob exit","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(fail","keyArg":"code","args":{"force":"force"},"job":"ojob exit","nolog":false,"map":true,"attrs":{"(fail":"code","((force":"force"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Ends all processing with an exit code","expects":[{"name":"code","desc":"The exit code number to use"},{"name":"force","desc":"A boolean indicating if instead of exit the processing should halt"}]},"each":[],"exec":"\n$$(args).set(\"code\", _$($$(args).get(\"code\"), \"Job (ojob exit), args [code]\").toNumber().isNumber().default(0));$$(args).set(\"force\", _$($$(args).get(\"force\"), \"Job (ojob exit), args [force]\").toBoolean().isBoolean().default(false))\n\nexit(args.code,args.force)"},{"name":"ojob print md","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(printmd","keyArg":"__text","args":{"outputMD":"__outputMD"},"job":"ojob print md","nolog":false,"map":true,"attrs":{"(printmd":"__text","((outputMD":"__outputMD"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Parses an input text as simple ascii markdown","expects":[{"name":"__text","desc":"The text template to parse."},{"name":"__outputMD","desc":"A boolean flag that if true will no parse the input text"}]},"each":[],"exec":"\n$$(args).set(\"__text\", _$($$(args).get(\"__text\"), \"Job (ojob print md), args [__text]\").isString().$_());$$(args).set(\"__outputMD\", _$($$(args).get(\"__outputMD\"), \"Job (ojob print md), args [__outputMD]\").toBoolean().isBoolean().default(false))\n\nvar a=clone(args);delete a.__text;args.__outputMD?printnl($t(args.__text,a)):printnl(ow.format.withMD($t(args.__text,a)));Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"}] \ No newline at end of file +[{"name":"ojob deps report","type":"simple","args":{},"deps":[],"help":{"text":"Outputs a tree list for each defined job (excluding \"ojob *\") and a comma delimited list of dependencies with a status flag"},"each":[],"exec":"\n\nvar b={};$from($ch(\"oJob::log\").getAll()).notStarts(\"name\",\"ojob \").select(function(a){b[a.name]=a.start?a.success?ansiColor(\"GREEN\",\"\\u2713\"):a.deps?a.error?ansiColor(\"RED\",\"\\u2715\"):ansiColor(\"BLUE\",\"\\u25b7\"):ansiColor(\"RED\",\"\\u2715\"):ansiColor(\"YELLOW\",\"\\u23f8\")});var c={};$from($ch(\"oJob::jobs\").getAll()).notStarts(\"name\",\"ojob \").select(function(a){c[a.name]=a.deps.map(function(d){return b[d]+\" \"+d}).join(\", \")});ow.oJob.output(c,{__format:\"tree\"})"},{"name":"ojob job report","type":"simple","args":{},"deps":[],"help":{"text":"Outputs a job jobs report (e.g. job name, action and plan)","expects":[{"name":"__format","desc":"Can be json, yaml, table (default) or any other ow.oJob.output format"}]},"each":[],"exec":"\n\now.oJob.output($ch(\"_ojob_plan\").getAll(),{__format:_$(args.__format).default(\"table\")})"},{"name":"ojob job","type":"simple","typeArgs":{"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Provides a way to organize idempotent jobs. One or more \"checks\" jobs will be called to determine an args._action.\nInitially the args._action is set to \"none\". If the \"checks\" jobs determine an action it will call the corresponding\njobs on \"actions\" jobs. If \"_go=true\" is not provided, instead of running, it will only return a plan of actions. \nFor example:\n\n - name: Write Hello World\n to : ojob job\n args:\n _checks : Check Hello World\n _actions:\n create : Create Hello World\n overwrite: Overwrite Hello World\n delete : Delete Hello World\n","expects":[{"name":"_checks","desc":"A list of one or more jobs to be called to perform checks to determine an args._action"},{"name":"_actions","desc":"A map of possible values of args._action whose values are one or more jobs to execute"},{"name":"_go","desc":"A boolean value (defaults to false) that controls if the _actions jobs are called (when true) or not"}]},"each":[],"exec":"\n$$(args).set(\"_go\", _$($$(args).get(\"_go\"), \"Job (ojob job), args [_go]\").toBoolean().isBoolean().default(false))\n\nisString(args._checks)&&(args._checks=[args._checks]);isString(args._actions)&&(args._actions={none:args._actions});var c=function(a){a=clone(a);delete a._checks;delete a._actions;return a};args._action=\"none\";args._checks.forEach(function(a){isString(a)?(a=$job(a,c(args)),isMap(a)&&isString(a._action)&&(args._action=a._action)):logErr(\"oJob Job 'checks' must be job names\")});$ch(\"_ojob_plan\").create();$ch(\"_ojob_plan\").get({name:job.name});var d=[];if(isDef(args._actions[args._action])){var b;\nisArray(args._actions[args._action])&&(b=args._actions[args._action]);isString(args._actions[args._action])&&(b=[args._actions[args._action]]);b.forEach(function(a){args._go?$job(a,c(args)):d.push(a)})}$ch(\"_ojob_plan\").set({name:job.name},{name:job.name,action:args._action,\"go?\":args._go,plan:d})"},{"name":"ojob report","type":"simple","args":{},"deps":[],"help":{"text":"Outputs a jobs report (e.g. job name, status, number of executions, total time, avg time and last execution)","expects":[{"name":"__format","desc":"Can be json, yaml, table (default) or any other ow.oJob.output format"}]},"each":[],"exec":"\n\now.loadFormat();print(\"\\n\");var b=$ch(\"oJob::log\").getAll(),c=$from(b).notEquals(\"name\",\"ojob report\").notEquals(\"name\",\"ojob final report\").select(function(a){return{\"Job name\":a.name,Status:a.start?a.success?\"OK\":a.deps?a.error?\"NOT OK!\":\"executing\":\"failed deps\":\"not started\",\"# execs\":a.count,\"Total time\":ow.format.elapsedTime4ms(a.totalTime,{abrev:!0}),\"Avg time\":ow.format.elapsedTime4ms(a.avgTime,{abrev:!0}),\"Last exec\":0args.__fn.indexOf(\".\")&&(args.__fn=\"global.\"+args.__fn);var a=$fnM(args.__fn,isDef(args.__path)?$path(args,args.__path):args);isString(args.__fnPath)&&(a=$$({}).set(args.__fnPath,a));isString(args.__key)?$set(args.__key,a):args=merge(args,a);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob output","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(output","keyArg":"__key","args":{"path":"__path","format":"__format","title":"__title","internal":"__internal","query":"__query","csv":"__csv","function":"__function"},"job":"ojob output","nolog":false,"map":true,"attrs":{"(output":"__key","((path":"__path","((format":"__format","((title":"__title","((internal":"__internal","((query":"__query","((csv":"__csv","((function":"__function"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Prints the current arguments to the console.","expects":[{"name":"__key","desc":"The key string to retrieve previous results (defaults to 'res'). If \"args\" will retrieve from current args."},{"name":"__path","desc":"A path string to a map/array over the results set on key."},{"name":"__format","desc":"The output format (e.g. see ow.oJob.output help)"},{"name":"__title","desc":"Encapsulates the output map/array with a title key."},{"name":"__internal","desc":"Boolean value that if true it will display the internal oJob entries on the arguments (default false)"},{"name":"__function","desc":"One of the OpenAF's print or log functions available"}]},"each":[],"exec":"\n\nisUnDef(args.__key)&&isDef(args.key)&&(args.__key=args.key);isUnDef(args.__path)&&isDef(args.path)&&(args.__path=args.path);isUnDef(args.__format)&&isDef(args.format)&&(args.__format=args.format);isUnDef(args.__title)&&isDef(args.title)&&(args.__title=args.title);isUnDef(args.__internal)&&isDef(args.internal)&&(args.__internal=args.internal);if(isString(args.__function))if(0<=args.__function.indexOf(\"print\")||0<=args.__function.indexOf(\"log\")){if(!(0<=af.fromJavaArray(af.getScopeIds()).map(function(b){return String(b)}).indexOf(args.__function)))throw\"__function '\"+\nargs.__function+\"' not found.\";args.__function=global[args.__function]}else throw\"__function needs to be a 'print' or 'log' function\";else args.__function=__;args.__key=_$(args.__key,\"key\").isString().default(\"res\");\"\"==args.__key&&(args.__key=\"res\");var a=\"args\"==args.__key?args:$get(args.__key);isUnDef(a)&&(a=args);!isDef(a)||isNull(a)||toBoolean(args.__internal)||(delete a.objId,delete a.execid,delete a.id);isDef(args.format)&&(args.__format=args.format,delete args.format);isDef(args.__path)&&\n(a=$path(a,args.__path),delete args.__path);isMap(a)&&isDef(a._list)&&(a=a._list);isMap(a)&&isDef(a._map)&&(a=a._map);if(isDef(args.__title)){var c={};c[args.__title]=a;ow.oJob.output(c,args,args.__function)}else ow.oJob.output(a,args,args.__function);Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob final report","type":"shutdown","args":{},"deps":[],"help":{"text":"Outputs a jobs report (e.g. job name, status, number of executions, total time, avg time and last execution) upon ojob termination","expects":[{"name":"__format","desc":"Can be json, yaml, table (default) or any other ow.oJob.output format"}]},"to":"ojob report","each":"\n","exec":"\n\nargs = ow.oJob.__processArgs(args, {})\n\n\n\n\now.loadFormat();print(\"\\n\");var b=$ch(\"oJob::log\").getAll(),c=$from(b).notEquals(\"name\",\"ojob report\").notEquals(\"name\",\"ojob final report\").select(function(a){return{\"Job name\":a.name,Status:a.start?a.success?\"OK\":a.deps?a.error?\"NOT OK!\":\"executing\":\"failed deps\":\"not started\",\"# execs\":a.count,\"Total time\":ow.format.elapsedTime4ms(a.totalTime,{abrev:!0}),\"Avg time\":ow.format.elapsedTime4ms(a.avgTime,{abrev:!0}),\"Last exec\":0args.validStates.indexOf(args.state)&&(isDef(args.default)?args.state=args.default:args.state=__);isString(args.state)&&isDef(ow.oJob.setState)&&ow.oJob.setState(args.state)"},{"name":"ojob todo","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(todo","keyArg":"todo","args":{"isolateArgs":"isolateArgs","isolateJob":"isolateJob","templateArgs":"templateArgs","shareArgs":"shareArgs","debug":"__debug"},"job":"ojob todo","nolog":false,"map":true,"attrs":{"(todo":"todo","((isolateArgs":"isolateArgs","((isolateJob":"isolateJob","((templateArgs":"templateArgs","((shareArgs":"shareArgs","((debug":"__debug"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Executes an ojob sub-todo.\nNOTE: doesn't perform any checks for recursive behaviour!","expects":[{"name":"todo","desc":"A string or array of todo' maps"},{"name":"todo[].name","desc":"Name of the job to execute"},{"name":"todo[].args","desc":"Arguments to merge (if isolateArgs is not true) with the main job arguments"},{"name":"todo[].isolateArgs","desc":"Boolean to indicate, for a specific todo, that args should be isolated from all others"},{"name":"todo[].isolateJob","desc":"Boolean to indicate, for a specific todo, that the job should run in a different scope (e.g. deps will not work)"},{"name":"todo[].templateArgs","desc":"Boolean to indicate, for a specific todo, to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"isolateArgs","desc":"Boolean, false by default, to indicate that args should be isolated from all others"},{"name":"isolateJob","desc":"Boolean, false by default, to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean, true by default, to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"shareArgs","desc":"Boolean, false by default, to indicate that args should be shared between all todo's jobs sequentially."},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"each":[],"exec":"\n$$(args).set(\"isolateArgs\", _$($$(args).get(\"isolateArgs\"), \"Job (ojob todo), args [isolateArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"isolateJob\", _$($$(args).get(\"isolateJob\"), \"Job (ojob todo), args [isolateJob]\").toBoolean().isBoolean().default(false));$$(args).set(\"templateArgs\", _$($$(args).get(\"templateArgs\"), \"Job (ojob todo), args [templateArgs]\").toBoolean().isBoolean().default(true));$$(args).set(\"shareArgs\", _$($$(args).get(\"shareArgs\"), \"Job (ojob todo), args [shareArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"__debug\", _$($$(args).get(\"__debug\"), \"Job (ojob todo), args [__debug]\").toBoolean().isBoolean().default(false))\n\nif(!isString(args.todo)&&!isArray(args.todo))throw\"todo needs to be a string or an array\";isString(args.todo)&&(args.todo=[args.todo]);var a=clone(args);delete a.todo;delete a.isolateArgs;delete a.templateArgs;delete a.shareArgs;delete a.__debug;args.todo.forEach(function(b){if(!isMap(b)&&!isString(b))throw\"todo entry needs to be a map or a string (\"+af.toSLON(b)+\")\";b=$job(\"ojob run\",{job:b,id:ow.oJob.__id,isolateArgs:args.isolateArgs,isolateJob:args.isolateJob,templateArgs:args.templateArgs,\n__debug:args.__debug,args:a});args.shareArgs&&(a=merge(a,b))})"},{"name":"ojob run","type":"simple","typeArgs":{"noLog":true,"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Executes an ojob but alternatively use 'ojob todo' or $job for most functionality.","expects":[{"name":"job","desc":"Name of the job to execute"},{"name":"id","desc":"The oJob id to execute (leave undefined to default to the current one)"},{"name":"args","desc":"The args to consider on execution."},{"name":"isolateArgs","desc":"Boolean to indicate that args should be isolated."},{"name":"isolateJob","desc":"Boolean to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"each":[],"exec":"\n$$(args).set(\"job\", _$($$(args).get(\"job\"), \"Job (ojob run), args [job]\").default(__));$$(args).set(\"id\", _$($$(args).get(\"id\"), \"Job (ojob run), args [id]\").isString().default(ow.oJob.__id));$$(args).set(\"isolateArgs\", _$($$(args).get(\"isolateArgs\"), \"Job (ojob run), args [isolateArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"isolateJob\", _$($$(args).get(\"isolateJob\"), \"Job (ojob run), args [isolateJob]\").toBoolean().isBoolean().default(false));$$(args).set(\"templateArgs\", _$($$(args).get(\"templateArgs\"), \"Job (ojob run), args [templateArgs]\").toBoolean().isBoolean().default(true));$$(args).set(\"__debug\", _$($$(args).get(\"__debug\"), \"Job (ojob run), args [__debug]\").toBoolean().isBoolean().default(false))\n\nif(!isString(args.job)&&!isMap(args.job))throw\"job needs to be either a string or job map\";isString(args.job)&&(args.job={name:args.job});args.job.templateArgs=_$(args.job.templateArgs,\"templateArgs \"+args.job.name).isBoolean().default(args.templateArgs);args.job.isolateArgs=_$(args.job.isolateArgs,\"isolateArgs \"+args.job.name).isBoolean().default(args.isolateArgs);args.job.isolateJob=_$(args.job.isolateJob,\"isolateJob \"+args.job.name).isBoolean().default(args.isolateJob);args.job.templateArgs&&\nisDef(args.args)&&args.job.templateArgs&&isDef(args.job.args)&&(isString(args.job.args)&&(args.job.args=ow.oJob.__processArgs(args.job.args)),traverse(args.job.args,function(c,b,e,d){isString(b)&&(d[c]=templify(b,args))}));args.job=ow.oJob.parseTodo(args.job);var a={name:args.job.name,args:args.job.isolateArgs?args.job.args:merge(args.args,args.job.args),id:args.job.isolateJob?__:args.id};args.__debug&&cprint(ow.format.withSideLine(printTreeOrS(a,__,{bgcolor:\"BG(235)\"}),__,\"FG(240)\",\"BG(235)\",ow.format.withSideLineThemes().openBottomCurvedRect));\nargs=merge(args,$job(a.name,a.args,a.id))"},{"name":"ojob run file","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(runfile","keyArg":"__job","args":{"args":"__args","out":"__out","key":"__key","inKey":"__inKey","usePM":"__usePM","inPM":"__inPM","templateArgs":"__templateArgs","debug":"__debug"},"job":"ojob run file","nolog":false,"map":true,"attrs":{"(runfile":"__job","((args":"__args","((out":"__out","((key":"__key","((inKey":"__inKey","((usePM":"__usePM","((inPM":"__inPM","((templateArgs":"__templateArgs","((debug":"__debug"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Executes an external YAML/JSON ojob file or a remote URL with the provided args.","expects":[{"name":"__job","desc":"The YAML/JSON ojob file or remote URL to run"},{"name":"__args","desc":"The args to provide to the external ojob file/url"},{"name":"__out","desc":"The path on args to set the map key/path contents"},{"name":"__key","desc":"If __out is not defined will set the content into the provided key"},{"name":"__inKey","desc":"If defined, args will be merged with the content from the provided key"},{"name":"__usePM","desc":"Output to __pm"},{"name":"__inPM","desc":"Input from provided key to __pm"},{"name":"__templateArgs","desc":"Boolean to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"__debug","desc":"Boolean to indicate that the job execution parameters should be printed before executing"}]},"each":[],"exec":"\n$$(args).set(\"__job\", _$($$(args).get(\"__job\"), \"Job (ojob run file), args [__job]\").isString().$_());$$(args).set(\"__args\", _$($$(args).get(\"__args\"), \"Job (ojob run file), args [__args]\").isMap().default({}));$$(args).set(\"__out\", _$($$(args).get(\"__out\"), \"Job (ojob run file), args [__out]\").isString().default(__));$$(args).set(\"__key\", _$($$(args).get(\"__key\"), \"Job (ojob run file), args [__key]\").isString().default(\"res\"));$$(args).set(\"__inKey\", _$($$(args).get(\"__inKey\"), \"Job (ojob run file), args [__inKey]\").isString().default(__));$$(args).set(\"__usePM\", _$($$(args).get(\"__usePM\"), \"Job (ojob run file), args [__usePM]\").toBoolean().isBoolean().default(false));$$(args).set(\"__inPM\", _$($$(args).get(\"__inPM\"), \"Job (ojob run file), args [__inPM]\").isString().default(__));$$(args).set(\"__templateArgs\", _$($$(args).get(\"__templateArgs\"), \"Job (ojob run file), args [__templateArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"__debug\", _$($$(args).get(\"__debug\"), \"Job (ojob run file), args [__debug]\").toBoolean().isBoolean().default(false))\n\nvar c=\"args\"==args.__key?\"r\"+nowNano():args.__key;args.__templateArgs&&isDef(args.__args)&&traverse(args.__args,function(b,d,g,f){isString(d)&&(f[b]=templify(d,args))});if(args.__usePM){var a={__format:\"pm\"};args.__key=__;args.__usePM=__}else a={__format:\"key\",__key:c};if(isDef(args.__inKey)){var e=$get(args.__inKey);a=merge(isDef(e)?merge(args.__args,e):args.__args,a)}else a=merge(args.__args,a);isDef(args.__inPM)&&ow.oJob.output($get(args.__inPM),{__format:\"pm\"});args.__debug&&cprint(ow.format.withSideLine(printTreeOrS(a,\n__,{bgcolor:\"BG(235)\"}),__,\"FG(235)\",\"BG(235)\",ow.format.withSideLineThemes().openBottomCurvedRect));ow.oJob.runFile(args.__job,a,c,!0,{shareArgs:!1});if(\"args\"==args.__key||\"res\"==args.__key)a=$get(c),isDef(a)&&(delete a.__format,delete a.__key,args=merge(args,a),\"args\"==args.__key&&$unset(c));Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"},{"name":"ojob parallel","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(parallel","keyArg":"todo","job":"ojob parallel","nolog":false,"map":true,"attrs":{"(parallel":"todo"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Executes an ojob sub-todo in parallel.\nNOTE: doesn't perform any checks for recursive behaviour!","expects":[{"name":"todo","desc":"A string or array of todo' maps"},{"name":"todo[].name","desc":"Name of the job to execute"},{"name":"todo[].args","desc":"Arguments to merge (if isolateArgs is not true) with the main job arguments"},{"name":"todo[].isolateArgs","desc":"Boolean to indicate, for a specific todo, that args should be isolated from all others"},{"name":"todo[].isolateJob","desc":"Boolean to indicate, for a specific todo, that the job should run in a different scope (e.g. deps will not work)"},{"name":"todo[].templateArgs","desc":"Boolean to indicate, for a specific todo, to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"isolateArgs","desc":"Boolean, false by default, to indicate that args should be isolated from all others"},{"name":"isolateJob","desc":"Boolean, false by default, to indicate that the job should run in a different scope (e.g. deps will not work)"},{"name":"templateArgs","desc":"Boolean, true by default, to indicate to apply template to each string of the provided args (use only if typeArgs.noTemplateArgs = false OR job.templateArgs = true)"},{"name":"shareArgs","desc":"Boolean, false by default, to indicate that args should be shared between all todo's jobs sequentially."},{"name":"__debug","desc":"Boolean to indicate that each job execution parameters should be printed before executing"}]},"each":[],"exec":"\n$$(args).set(\"isolateArgs\", _$($$(args).get(\"isolateArgs\"), \"Job (ojob parallel), args [isolateArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"isolateJob\", _$($$(args).get(\"isolateJob\"), \"Job (ojob parallel), args [isolateJob]\").toBoolean().isBoolean().default(false));$$(args).set(\"templateArgs\", _$($$(args).get(\"templateArgs\"), \"Job (ojob parallel), args [templateArgs]\").toBoolean().isBoolean().default(true));$$(args).set(\"shareArgs\", _$($$(args).get(\"shareArgs\"), \"Job (ojob parallel), args [shareArgs]\").toBoolean().isBoolean().default(false));$$(args).set(\"__debug\", _$($$(args).get(\"__debug\"), \"Job (ojob parallel), args [__debug]\").toBoolean().isBoolean().default(false))\n\nif(!isString(args.todo)&&!isArray(args.todo))throw\"todo needs to be a string or an array\";isString(args.todo)&&(args.todo=[args.todo]);var a=clone(args),c=[];delete a.todo;delete a.isolateArgs;delete a.templateArgs;delete a.shareArgs;delete a.__debug;args.todo.forEach(function(b){if(!isMap(b)&&!isString(b))throw\"todo entry needs to be a map or a string (\"+af.toSLON(b)+\")\";c.push($do(function(){return $job(\"ojob run\",{job:b,id:ow.oJob.__id,isolateArgs:args.isolateArgs,isolateJob:args.isolateJob,\ntemplateArgs:args.templateArgs,__debug:args.__debug,args:a})}))});$doWait($doAll(c))"},{"name":"ojob wait","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(wait","keyArg":"time","job":"ojob wait","nolog":false,"map":true,"attrs":{"(wait":"time"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Waits for a specific amount of time","expects":[{"name":"time","desc":"The amount of time, in ms, to pause execution"}]},"each":[],"exec":"\n$$(args).set(\"time\", _$($$(args).get(\"time\"), \"Job (ojob wait), args [time]\").toNumber().isNumber().$_())\n\nsleep(args.time,!0)"},{"name":"ojob exit","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(fail","keyArg":"code","args":{"force":"force"},"job":"ojob exit","nolog":false,"map":true,"attrs":{"(fail":"code","((force":"force"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Ends all processing with an exit code","expects":[{"name":"code","desc":"The exit code number to use"},{"name":"force","desc":"A boolean indicating if instead of exit the processing should halt"}]},"each":[],"exec":"\n$$(args).set(\"code\", _$($$(args).get(\"code\"), \"Job (ojob exit), args [code]\").toNumber().isNumber().default(0));$$(args).set(\"force\", _$($$(args).get(\"force\"), \"Job (ojob exit), args [force]\").toBoolean().isBoolean().default(false))\n\nexit(args.code,args.force)"},{"name":"ojob print md","type":"simple","typeArgs":{"noLog":true,"shortcut":{"name":"(printmd","keyArg":"__text","args":{"outputMD":"__outputMD"},"job":"ojob print md","nolog":false,"map":true,"attrs":{"(printmd":"__text","((outputMD":"__outputMD"}},"lang":"oaf","lockCh":"oJob::locks"},"args":{},"deps":[],"help":{"text":"Parses an input text as simple ascii markdown","expects":[{"name":"__text","desc":"The text template to parse."},{"name":"__outputMD","desc":"A boolean flag that if true will no parse the input text"}]},"each":[],"exec":"\n$$(args).set(\"__text\", _$($$(args).get(\"__text\"), \"Job (ojob print md), args [__text]\").isString().$_());$$(args).set(\"__outputMD\", _$($$(args).get(\"__outputMD\"), \"Job (ojob print md), args [__outputMD]\").toBoolean().isBoolean().default(false))\n\nvar a=clone(args);delete a.__text;args.__outputMD?printnl($t(args.__text,a)):printnl(ow.format.withMD($t(args.__text,a)));Object.keys(args).filter(function(b){return b.startsWith(\"__\")}).forEach(function(b){return delete args[b]})"}] \ No newline at end of file diff --git a/ojob.yaml b/ojob.yaml index d3fe5dfe..35b22ff0 100644 --- a/ojob.yaml +++ b/ojob.yaml @@ -1395,10 +1395,11 @@ jobs: if (isDef(args.__from)) f = $path(f, args.__from) ow.loadObj() - if (isDef(args.__type) && args.__type == "path") { - f = $path(f, args.__query) - } else { - f = ( isString(args.__query) ? $from(f).query(af.fromNLinq(args.__query)) : $from(f).query(args.__query) ) + switch(args.__type) { + case "path" : f = $path(f, args.__query); break + case "sql" : f = $sql(f, args.__query); break + case "nlinq": + default : f = ( isString(args.__query) ? $from(f).query(af.fromNLinq(args.__query)) : $from(f).query(args.__query) ) } if (args.__key != "args") { diff --git a/src/openaf/plugins/GIT.java b/src/openaf/plugins/GIT.java deleted file mode 100644 index 4eca96f2..00000000 --- a/src/openaf/plugins/GIT.java +++ /dev/null @@ -1,402 +0,0 @@ -package openaf.plugins; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.lang.String; - -import org.eclipse.jgit.api.CheckoutCommand; -import org.eclipse.jgit.api.CloneCommand; -import org.eclipse.jgit.api.CommitCommand; -import org.eclipse.jgit.api.FetchCommand; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.Status; -import org.eclipse.jgit.api.TransportCommand; -import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.api.errors.InvalidRemoteException; -import org.eclipse.jgit.api.errors.TransportException; -import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; -import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.revwalk.RevCommit; -import org.mozilla.javascript.Scriptable; -import org.mozilla.javascript.ScriptableObject; -import org.mozilla.javascript.Undefined; -import org.mozilla.javascript.annotations.JSConstructor; -import org.mozilla.javascript.annotations.JSFunction; -import openaf.AFCmdBase; - -/** - * GIT plugin - * - * Copyright 2023 Nuno Aguiar - * - */ -public class GIT extends ScriptableObject { - - /** - * - */ - private static final long serialVersionUID = 1L; - protected String login; - protected String pass; - - @Override - public String getClassName() { - return "GIT"; - } - - protected Git git; - - /** - * - * GIT.GIT(aDirectory, aUser, aPassword) - * Creates a GIT object instance to access a GIT repository on the aDirectory provided. - * Optionally you can provide also a login and password for remote repositories. - * - */ - @JSConstructor - public void newGIT(Object dir, Object alogin, Object apass) throws IOException { - // Remove JGit logging except for errors - //((org.slf4j.helpers.NOPLogger) LoggerFactory.getLogger(org.eclipse.jgit.util.FS.class)).setLevel(ch.qos.logback.classic.Level.ERROR); - //((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.eclipse.jgit.util.FS.class)).setLevel(ch.qos.logback.classic.Level.ERROR); - //((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.eclipse.jgit.util.FS_Win32.class)).setLevel(ch.qos.logback.classic.Level.ERROR); - //((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.eclipse.jgit.util.FS_Win32_Cygwin.class)).setLevel(ch.qos.logback.classic.Level.ERROR); - //((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.eclipse.jgit.util.FS_POSIX.class)).setLevel(ch.qos.logback.classic.Level.ERROR); - open(dir); - if (alogin != null && !(alogin instanceof Undefined) && - apass != null && !(apass instanceof Undefined)) { - login = AFCmdBase.afc.dIP((String) alogin); - pass = AFCmdBase.afc.dIP((String) apass); - } - } - - /** - * - * GIT.open(aDirectory) - * Opens a GIT repository on the aDirectory provided. - * - * @throws IOException - */ - @JSFunction - public void open(Object dir) throws IOException { - if (!(dir instanceof Undefined) && !((String) dir).equals("")) { - git = Git.open(new File((String) dir)); - } - } - - /** - * - * GIT.init(aDirectory) - * Initializes a GIT repository on the aDirectory provided. - * - */ - @JSFunction - public void init(Object dir) throws IllegalStateException, GitAPIException { - if (!(dir instanceof Undefined) && !((String) dir).equals("")) { - git = Git.init().setDirectory(new File((String) dir)).call(); - } - } - - /** - * - * GIT.clone(aURL, aDirectory, cloneAll, aBranchName, aUser, aPassword) - * Clones aURL GIT repository to the aDirectory provided. Optionally, if you want all branches cloned you can indicate that - * with cloneAll = true. If don't want all branches cloned but a specific one you can indicate it with aBranchName. - * - */ - @JSFunction - public void clone(Object aURL, Object dir, boolean cloneAll, Object branch, String aUser, String aPass) throws InvalidRemoteException, TransportException, GitAPIException { - if (!(dir instanceof Undefined) && !((String) dir).equals("") && !(aURL instanceof Undefined) && !((String) aURL).equals("")) { - CloneCommand clone = ((CloneCommand) setCred(Git.cloneRepository())).setURI((String) aURL).setDirectory(new File((String) dir)); - if (!(branch instanceof Undefined) && !((String) branch).equals("")) { - clone = clone.setBranchesToClone(Collections.singleton((String) branch)); - clone = clone.setBranch((String) branch); - clone = clone.setCloneAllBranches(cloneAll); - } - if (aUser != null && aPass != null) clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(AFCmdBase.afc.dIP(aUser), AFCmdBase.afc.dIP(aPass))); - git = clone.call(); - } - } - - /** - * - * GIT.checkout(aPath, aBranchName) : JavaRef - * Checkouts the current GIT repository to aPath. Optionally you can provide aBranchName to checkout a specific branch. - * - */ - @JSFunction - public Object checkout(Object aPath, Object aBranchName) throws Exception { - if (git != null) { - CheckoutCommand check = git.checkout(); - if (!(aBranchName instanceof Undefined) && !((String) aBranchName).equals("")) - check = check.setName((String) aBranchName); - Ref checkout; - if (!(aPath instanceof Undefined) && !((String) aPath).equals("")) - checkout = check.addPath((String) aPath).call(); - else - checkout = check.call(); - return checkout; - } else { - throw new Exception("Repository not open"); - } - } - - /** - * - * GIT.add(aFilePattern) : JavaDirCache - * Adds a given aFilePattern (e.g. "some.file.txt" or "someFiles*") to the current open repository. Throws a "Repository not open" - * exception if the repository is not open. - * - * @throws Exception - */ - @JSFunction - public Object add(String aFilePattern) throws Exception { - if (git != null) - return git.add().addFilepattern(aFilePattern).call(); - else - throw new Exception("Repository not open"); - } - - /** - * - * GIT.remove(aFilePattern) - * Removes a given aFilePattern (e.g. "some.file.txt" or "someFiles*") from the current open repository. Throws an exception if not possible. - * - */ - @JSFunction - public void remove(String aFilePattern) throws Exception { - if (git != null) - git.rm().addFilepattern(aFilePattern).call(); - else - throw new Exception("Repository not open"); - } - - @JSFunction - public Object getStatus(Object aDirectory) throws Exception { - Scriptable record = (Scriptable) AFCmdBase.jse.newObject(AFCmdBase.jse.getGlobalscope()); - - Status status; - if (git != null) { - if (!(aDirectory instanceof Undefined) && !((String) aDirectory).equals("")) { - status = git.status().addPath((String) aDirectory).call(); - } else { - status = git.status().call(); - } - - record.put("added", record, AFCmdBase.jse.newArray(record, status.getAdded().toArray())); - record.put("changed", record, AFCmdBase.jse.newArray(record, status.getChanged().toArray())); - record.put("conflicting", record, AFCmdBase.jse.newArray(record, status.getConflicting().toArray())); - record.put("ignoredNotInIndex", record, AFCmdBase.jse.newArray(record, status.getIgnoredNotInIndex().toArray())); - record.put("missing", record, AFCmdBase.jse.newArray(record, status.getMissing().toArray())); - record.put("modified", record, AFCmdBase.jse.newArray(record, status.getModified().toArray())); - record.put("removed", record, AFCmdBase.jse.newArray(record, status.getRemoved().toArray())); - } else - throw new Exception("Repository not open"); - - return record; - } - - /** - * - * GIT.getJavaGit() : JavaGit - * Returns the internal Java GIT object. - * - */ - @JSFunction - public Object getJavaGit() { - return git; - } - - protected TransportCommand setCred(TransportCommand c) { - if (login != null & pass != null) { - c.setCredentialsProvider(new UsernamePasswordCredentialsProvider(login, pass)); - } - - return c; - } - - /** - * - * GIT.push() - * Performs a push command on the current opened GIT repository. - * - */ - @JSFunction - public void push() throws Exception { - if (git != null) - setCred(git.push()).call(); - else - throw new Exception("Repository not open"); - } - - /** - * - * GIT.pull() - * Performs a pull command on the current opened GIT repository. - * - */ - @JSFunction - public void pull() throws Exception { - if (git != null) - setCred(git.pull()).call(); - else - throw new Exception("Repository not open"); - } - - - /** - * - * GIT.fetch(aRemote) - * Performs a fetch command on the current open GIT repository. - * Optionally you can provide aRemote. - * - * @throws Exception - */ - @JSFunction - public void fetch(Object aRemote) throws Exception { - if (git != null) { - FetchCommand fetch = (FetchCommand) setCred(git.fetch()); - if (!(aRemote instanceof Undefined) && !((String) aRemote).equals("")) { - fetch = fetch.setRemote((String) aRemote); - } - fetch.call(); - } - else - throw new Exception("Repository not open"); - } - - /** - * - * GIT.branchCreate(aBranchName) - * Creates a branch with the provided aBranchName on the current open GIT repository. - * - */ - @JSFunction - public void branchCreate(String aBranchName) throws Exception { - if (git != null) - git.branchCreate().setName(aBranchName).call(); - else - throw new Exception("Repository not open"); - } - - /** - * - * GIT.branchRename(aOldName, aNewName) - * Renames aOldName branch with aNewName on the current open GIT repository. - * - */ - @JSFunction - public void branchRename(String oldName, String newName) throws Exception { - if (git != null) - git.branchRename().setOldName(oldName).setNewName(newName).call(); - else - throw new Exception("Repository not open"); - } - - /** - * - * GIT.branchDelete(aBranchName) - * Deletes a branch named aBranchName from the current open GIT repository. - * - */ - @JSFunction - public void branchDelete(String aBranchName) throws Exception { - if (git != null) - git.branchDelete().setBranchNames(aBranchName).call(); - else - throw new Exception("Repository not open"); - } - - /** - * - * GIT.branchList() - * Lists the name and objectId for each branch available on the current open GIT repository. - * - */ - @JSFunction - public Object branchList() throws Exception { - ArrayList records = new ArrayList(); - - if (git != null) { - List list = git.branchList().call(); - for(Ref i : list) { - Scriptable record = (Scriptable) AFCmdBase.jse.newObject(AFCmdBase.jse.getGlobalscope()); - - record.put("name", record, i.getName()); - record.put("objectId", record, i.getObjectId().getName()); - //record.put("target", record, i.getTarget()); - //record.put("peeledObjectId", record, i.getPeeledObjectId()); - - records.add(record); - } - } else - throw new Exception("Repository not open"); - - return AFCmdBase.jse.newArray(AFCmdBase.jse.getGlobalscope(), records.toArray()); - } - - /** - * - * GIT.branch() : String - * Returns the current branch for the repository. - * - */ - @JSFunction - public Object branch() throws Exception { - String branch = ""; - - if (git != null) { - branch = git.status().getRepository().getBranch(); - } - - return branch; - } - - @JSFunction - public Object remoteBranchList(String anURL) throws Exception { - if (git != null) { - return Git.lsRemoteRepository().setRemote(anURL).setHeads(true).call(); - } else { - throw new Exception("Repository not open"); - } - } - - /** - * - * GIT.close() - * Closes the current open GIT repository. - * - */ - @JSFunction - public void close() throws Exception { - if (git != null) - git.close(); - else - throw new Exception("Repository not open"); - } - - /** - * - * GIT.commit(aMessage, aName, anEmail) : JavaRevCommit - * Commits the current open GIT repository with aMessage provided. Throws an exception if not possible. - * Optionally you can also provide aName and anEmail. - * - * @throws Exception - */ - @JSFunction - public Object commit(String aMessage, Object name, Object email) throws Exception { - if (git != null) { - CommitCommand commit = git.commit().setMessage(aMessage); - if (!(name instanceof Undefined) && !((String) name).equals("") && - !(email instanceof Undefined) && !((String) email).equals("")) { - commit = commit.setAuthor((String) name, (String) email); - } - RevCommit revcommit = commit.call(); - return revcommit; - } - else - throw new Exception("Repository not open"); - } -} diff --git a/versionsAndDeps.json b/versionsAndDeps.json index 65bb8af1..53ad183e 100644 --- a/versionsAndDeps.json +++ b/versionsAndDeps.json @@ -390,22 +390,6 @@ "lib/commons-net-3.8.0.jar" ] }, - { - "name": "GIT", - "removable": true, - "deps": [ - "lib/org-eclipse-jgit-5.8.1.jar", - "lib/jsch-0.2.11.jar", - "lib/jsch.agentproxy.connector-factory-0.0.9.jar", - "lib/jsch.agentproxy.core-0.0.9.jar", - "lib/jsch.agentproxy.jsch-0.0.9.jar", - "lib/jsch.agentproxy.pageant-0.0.9.jar", - "lib/jsch.agentproxy.sshagent-0.0.9.jar", - "lib/jsch.agentproxy.svnkit-trilead-ssh2-0.0.9.jar", - "lib/jsch.agentproxy.usocket-jna-0.0.9.jar", - "lib/jsch.agentproxy.usocket-nc-0.0.9.jar" - ] - }, { "name": "HTTP", "removable": false,