[wpkg-users] wpkg.js TODO list

Daniel Dehennin daniel.dehennin at ac-caen.fr
Tue Jun 1 14:31:56 CEST 2010


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.wpkg.org/pipermail/wpkg-users/attachments/20100601/a14674f5/attachment.sig>


More information about the wpkg-users mailing list