Installing
----------

Drop the script anywhere, make it executable, optionally edit it and change
the default value of $EXTENSIONDIR. Run it with /bin/ash.

Using
-----

PLEASE NOTE USAGE: /bin/ash /path/to/aloop.sh [options]

# /bin/ash aloop.sh -h 
Usage: aloop.sh [options]
  parse menu files in /mnt/us/extensions

Options:
 -h | --help
 -c=MAX | --colors=MAX   : max cyclical index when -f=twolevel (default 0=off)
 -f=NAME | -format=NAME   : select output format, NAME is one of:
   default     default format, also when -f isn't specified, sortable
   debuginfo   dump xml_* and json_* variables
   touchrunner compatible with TouchRunner launcher, sortable
   twolevel    default + group name and color index, sortable, see also -c
 -s | --sort   : sort output by label
 
Limitations:
. Supports json menus only
. Supports one- or two-level menus only
. A menu entry must not extend across multiple lines. Example of a valid entry:
  {"name": "a label", "priority": 3, "action" : "foo.sh", "params": "p1,p2"}
  with or without a traling comma

Examples
--------
*** My favorite one is # 6 *** or # 7

# 1 simple label (without top menu name) + action, unsorted
/bin/ash aloop.sh

# 2 list of parsed values
/bin/ash aloop.sh -f=debuginfo

# 3 if you use the TouchRunner launcher
/bin/ash aloop.sh -f=touchrunner -s >> /mnt/us/touchrunner/commands.txt

# 4 for two-level nested menus, like Komic's, label = menu name + item name
/bin/ash aloop.sh -f=twolevel

# 5 sort the two-level index by menu (top) level name and leave
# sub-items in the same order they appear in their json file
/bin/ash aloop.sh -f=twolevel -s

# 6 prepend a rolling 'color index' which resets to zero every N menus
/bin/ash aloop.sh -f=twolevel -s -c=3

# 7 Use -c=999 if you want a serial index from 0 to 998
/bin/ash aloop.sh -f=twolevel -s -c=999

Release history
---------------
20130127,a,stepk
! colorizing is now disabled by default use -c=MAXCOLORS to enable, i.e. -c=2
+ K3 busybox ash compatibility layer complete! Now runs on K3 too.
  K5 version ran roughly 350% faster than K3 version (real time, one sample)
+ option -l | --log
! explicit shebang ash (defensive)
- fix: test applet install loop (defensive)
* minor tweaks and fixes
* tested on K3 and K5 /bin/ash (both running on KT)

20130126,b,stepk
- fix: K3 ash compatibility http://www.mobileread.com/forums/showpost.php?p=2397966&postcount=160

20130125,a,stepk
+ auto fix DOS line endings
+ added $PRODUCTNAME="Unified Kindle Launcher"
+ -c=0 disables color index output
+ if no menu items found install a test applet (411)
- fix: bail out on unknown script option
+ documentation: added README-dev.txt

20130124,a,stepk
+ option -h | --help
+ option --format=debuginfo
+ options --format=twolevel and -c=|--colors=N
+ config.xml and menu.json can reside in different folders
! search extensions by config.xml (was by menu.json)
! extract group (top) menu name from json file (was from config.xml)
- silently reject invalid xml/json files
+ documented parser's limitations (corner cases)
* code factorization

20130122,c,stepk
+ options --sort and --format=touchrunner

20130122,a,stepk
= first version