Last active
September 22, 2022 19:44
-
-
Save Risto-Stevcev/49efd7b7768c10f5e1b87618301891b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
?- use_module(library(optparse)). | |
true. | |
?- ExampleOptsSpec = | |
[ [opt(mode ), type(atom), default('SCAN'), | |
shortflags([m]), longflags(['mode'] ), | |
help([ 'data gathering mode, one of' | |
, ' SCAN: do this' | |
, ' READ: do that' | |
, ' MAKE: fabricate some numbers' | |
, ' WAIT: don''t do anything'])] | |
, [opt(cache), type(boolean), default(true), | |
shortflags([r]), longflags(['rebuild-cache']), | |
help('rebuild cache in each iteration')] | |
, [opt(threshold), type(float), default(0.1), | |
shortflags([t,h]), longflags(['heisenberg-threshold']), | |
help('heisenberg threshold')] | |
, [opt(depth), meta('K'), type(integer), default(3), | |
shortflags([i,d]),longflags([depths,iters]), | |
help('stop after K iterations')] | |
, [opt(distances), default([1,2,3,5]), | |
longflags([distances]), | |
help('initial prolog term')] | |
, [opt(outfile), meta('FILE'), type(atom), | |
shortflags([o]), longflags(['output-file']), | |
help('write output to FILE')] | |
, [opt(label), type(atom), default('REPORT'), | |
shortflags([l]), longflags([label]), | |
help('report label')] | |
, [opt(verbose), meta('V'), type(integer), default(2), | |
shortflags([v]), longflags([verbosity]), | |
help('verbosity level, 1 <= V <= 3')] | |
, [opt(path), default('/some/file/path/')] | |
]. | |
?- ExampleArgs = [ '-d5' | |
, '--heisenberg-threshold', '0.14' | |
, '--distances=[1,1,2,3,5,8]' | |
, '--iters', '7' | |
, '-ooutput.txt' | |
, '--rebuild-cache', 'true' | |
, 'input.txt' | |
, '--verbosity=2' | |
]. | |
?- opt_parse($ExampleOptsSpec, $ExampleArgs, Opts, PositionalArgs) . | |
Opts = [mode('SCAN'), label('REPORT'), path('/some/file/path/'), threshold(0.14), distances([1, 1, 2|...]), depth(7), outfile('output.t\ | |
xt'), cache(true), verbose(...)], | |
PositionalArgs = ['input.txt'], | |
ExampleOptsSpec = [[opt(mode), type(atom), default('SCAN'), shortflags([m]), longflags([mode]), help(['data gathering mode, one of'|...\ | |
])], [opt(cache), type(boolean), default(true), shortflags([r]), longflags(['rebuild-cache']), help('rebuild cache in each iteration')]\ | |
, [opt(threshold), type(float), default(0.1), shortflags([t|...]), longflags([...]), help(...)], [opt(depth), meta('K'), type(integer),\ | |
default(3), shortflags(...)|...], [opt(distances), default([1|...]), longflags([...]), help(...)], [opt(outfile), meta('FILE'), type(.\ | |
..)|...], [opt(label), type(...)|...], [opt(...)|...], [...|...]], | |
ExampleArgs = ['-d5', '--heisenberg-threshold', '0.14', '--distances=[1,1,2,3,5,8]', '--iters', '7', '-ooutput.txt', '--rebuild-cache',\ | |
true|...]. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment