diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-03 06:26:42 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-03 06:26:42 -0700 |
commit | 935f58e8941f03590bbd5c8482a31b50cf233802 (patch) | |
tree | 60e7aba15bda7669cf005af9ce5d4e058e52348f /lisplib.c | |
parent | d01a12405fbffb6a68345f72a510bf9e25e8ef95 (diff) | |
download | txr-935f58e8941f03590bbd5c8482a31b50cf233802.tar.gz txr-935f58e8941f03590bbd5c8482a31b50cf233802.tar.bz2 txr-935f58e8941f03590bbd5c8482a31b50cf233802.zip |
Introducing command line option processing system.
* lisplib.c (getopts_set_entries, getopts_instantiate): New
functions.
(lisplib_init): Register auto-loading for getopt.tl
via new functions.
* share/txr/stdlib/getopts.tl: New file.
* txr.1: Documented new library area.
Diffstat (limited to 'lisplib.c')
-rw-r--r-- | lisplib.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -387,6 +387,24 @@ static val trace_instantiate(val set_fun) return nil; } +static val getopts_set_entries(val dlt, val fun) +{ + val name[] = { + lit("opt-desc"), lit("opts"), + lit("opt"), lit("getopts"), lit("opthelp"), + nil + }; + set_dlt_entries(dlt, name, fun); + return nil; +} + +static val getopts_instantiate(val set_fun) +{ + funcall1(set_fun, nil); + load(format(nil, lit("~agetopts.tl"), stdlib_path, nao)); + return nil; +} + val dlt_register(val dlt, val (*instantiate)(val), val (*set_entries)(val, val)) @@ -419,6 +437,7 @@ void lisplib_init(void) dlt_register(dl_table, awk_instantiate, awk_set_entries); dlt_register(dl_table, build_instantiate, build_set_entries); dlt_register(dl_table, trace_instantiate, trace_set_entries); + dlt_register(dl_table, getopts_instantiate, getopts_set_entries); } val lisplib_try_load(val sym) |