[Nickle] New module for argument parsing.

Bart Massey bart at cs.pdx.edu
Mon May 17 23:33:57 PDT 2004


I've put my shiny new Nickle argument parser into the bits.
You can get it the obvious way, via
   autoimport ParseArgs;
Once it's loaded, you can use it kind of like the attached
incomprehensible example I have lying around.  Documentation
and polishing are still needed.  I'm waiting for Keith or I
to fix a core Nickle to get a couple more things working.
Comments and suggestions are appreciated.

	Bart

-------------- next part --------------
/* Generate the core of a homeostatic WeBL FP
 * PO8 po8 at po8.org  04 May 2004
 */

import String;
autoimport ParseArgs;

argdesc argd = {
    args = {
	{var = {arg_int = &(int center_agg = 5)},
	 abbr = 'a',
	 name = "estimated-agg",
	 expr_name = "agg-value",
	 desc = "Estimated aggression needed to barely win a round."},
	{var = {arg_real = &(real scale_agg = 2)},
	 abbr = 'A',
	 name = "scale-agg",
	 expr_name = "scale-quotient",
	 desc = "Scale aggression down to change the curve."},
	{var = {arg_int = &(int center_def = 13)},
	 abbr = 'd',
	 name = "estimated-def",
	 expr_name = "def-value",
	 desc = "Estimated defense needed for nominal damage."},
	{var = {arg_real = &(real damage_per_round = 2.3)},
	 abbr = 'D',
	 name = "damage-per-round",
	 expr_name = "damage",
	 desc = "Aim for this much damage per round."},
	{var = {arg_int = &(int round = 3)},
	 abbr = 'r',
	 name = "round",
	 expr_name = "round",
	 desc = "Plan starts at this round."},
	{var = {arg_string = &(string styles = "(outside),(ropes),(ring)")},
	 abbr = 's',
	 name = "styles",
	 expr_name = "(agg-style),(pow-style),(def-style)",
	 desc = "Offensive and defensive styles."},
    }
};
parseargs(&argd, &argv);
printf("# begin synthetic\n");
printf("# mkplan.5c FP 1.1\n");
printf("# --estimated-agg %d\n", center_agg); 
printf("# --scale-agg %g\n", scale_agg); 
printf("# --estimated_def %d\n", center_def); 
printf("# --damage-per-round %g\n", damage_per_round);
printf("# --styles %s\n", styles);

string[*] style_names = split(styles, ",");
string agg_style = style_names[0];
string pow_style = style_names[1];
string def_style = style_names[2];

/* Now variables such as center_agg have everything needed
   for the (omitted) calculations. */


More information about the Nickle mailing list