In using opt_help(usage,"p version 1.0 \nUsage: p [options]")
:
#!/usr/bin/env swipl
:- initialization(main, main).
main(Argv) :-
argv_options(Argv,_Pos,_Opts).
opt_type(s,stats,boolean).
opt_type(statistics,stats,boolean).
opt_type(v,verbosity,boolean).
opt_help(stats,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc at purus a elit mattis tempus. Morbi ligula ante, dapibus vestibulum posuere ac, luctus vel metus. Quisque aliquam justo vitae eleifend pretium. Quisque dignissim metus laoreet convallis dignissim. Curabitur varius enim quis justo hendrerit faucibus. Suspendisse potenti. \n \n Nullam vehicula aliquet consequat. Duis nec molestie enim. Etiam volutpat felis ante, quis sollicitudin orci tristique a. Suspendisse scelerisque purus consequat purus placerat bibendum. Vestibulum elementum aliquet feugiat. Ut in iaculis urna. Sed molestie orci urna, eu convallis purus faucibus cursus. ").
opt_help(verbosity,"Increase verbosity").
opt_help(usage,"p version 1.0 \nUsage: p [options]").
argv_options/3 prints the following:
Usage: swipl /tmp/p.pl p version 1.0
Usage: p [options]
Options:
-h, -?, --help Show this help message and exit
-s, --statistics Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc at purus a elit mattis tempus.
Morbi ligula ante, dapibus vestibulum posuere ac, luctus vel metus. Quisque aliquam justo
vitae eleifend pretium. Quisque dignissim metus laoreet convallis dignissim. Curabitur varius
enim quis justo hendrerit faucibus. Suspendisse potenti. Nullam vehicula aliquet consequat.
Duis nec molestie enim. Etiam volutpat felis ante, quis sollicitudin orci tristique a.
Suspendisse scelerisque purus consequat purus placerat bibendum. Vestibulum elementum aliquet
feugiat. Ut in iaculis urna. Sed molestie orci urna, eu convallis purus faucibus cursus.
-v Increase verbosity
In my opinion, I think it would be more useful if opt_help(usage,...)
would completely override the string printed before the options.
Thanks for your great work!
EDIT: Also, is there a way to override the -h
option and specify an alternative option for help? e.g. a program where you always specify a host may want to use -h <host>
and only use --help
for help (or maybe some other short option also).
EDIT 2: Perhaps opt_type(Something,help,boolean)
can be used for changing the help option? and maybe even opt_help(help,Something)
if the user wants to completely override what is printed?