Hello, Before looking at wpkg-test, I publish my wpkg.js improvements TODO list.
My next work will be to use generic option handling with minimal type validation: - boolean - string - number - list (array object or comma separated string) The idea is to use "argv/argn" in one place and avoid long series of "if(argn...)" and "if(isArgSet...)". Each call (17 in total) to "isArgSet" loops through "argv", I plan to replace it with 1 loop on argn, this will permit to detect unknown or misspelled arguments. Regards. Factorize options handling [0/4] ================================ Author: Daniel Dehennin Date: 2010-06-01 14:11:46 CEST Table of Contents ================= 1 Define global Option associative array 2 Define wrapper functions [0/5] 2.1 AddOpt(name, type, default): define or overwrite an option 2.2 isOpt(name): return true if option is defined, false otherwize 2.3 getOpt(name): get the value of an option 2.4 getOptType(name): get the type of an option (boolean, string, number, list) 2.5 setOpt(name, value): set a new value of an already defined option 3 Replace getArgv/argv/argn uses by getOpt()/setOpt() [0/5] 3.1 main() 3.2 getConfig() 3.3 getProfileList() 3.4 initialize() 3.5 parseArguments() 4 Remove useless isArgSet 1 TODO Define global Option associative array ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Option array store all the config.xml and command-line parameters options. 2 TODO Define wrapper functions [0/5] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Wrappers must works without log facilities => throw errors. 2.1 TODO AddOpt(name, type, default): define or overwrite an option ==================================================================== Each option in an entry in Option array like: Option[name] = new Array(type, default) 2.2 TODO isOpt(name): return true if option is defined, false otherwize ======================================================================== 2.3 TODO getOpt(name): get the value of an option ================================================== The option value is =Option[name][1]=. 2.4 TODO getOptType(name): get the type of an option (boolean, string, number, list) ===================================================================================== The type is =Option[name][0]=. 2.5 TODO setOpt(name, value): set a new value of an already defined option =========================================================================== Use addOpt to store the new value. Throw an error if the option is not already defined because getOptType is undefined otherwize. 3 TODO Replace getArgv/argv/argn uses by getOpt()/setOpt() [0/5] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3.1 TODO main() ================ 3.2 TODO getConfig() ===================== 3.3 TODO getProfileList() ========================== 3.4 TODO initialize() ====================== 3.5 TODO parseArguments() ========================== - Loop for boolean arguments in argv, report warning for unknown boolean (indexOf(":")==-1) - Loop for non boolean arguments in argn, report warning for unknown non boolean (value==undefined). 4 TODO Remove useless isArgSet ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Daniel Dehennin RAIP de l'Orne
pgpleBjqxFfLO.pgp
Description: PGP signature
------------------------------------------------------------------------- wpkg-users mailing list archives >> http://lists.wpkg.org/pipermail/wpkg-users/ _______________________________________________ wpkg-users mailing list wpkg-users@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/wpkg-users