[m-users.] getopt_io return value type on success?

Sean Charles (emacstheviking) objitsu at gmail.com
Sun Apr 25 05:56:56 AEST 2021


Hi,

I have managed to implement a working command line but I am struggling to figure out how to return the ok(X) value to my caller, I have written a predicate that I call from main():

    :- pred do_command_line(
	    list(string)::out,
	    getopt_io.option_table(?)::out,
	    io::di, io::uo
     ) is det.


I know that ok(X) indicates an option table is now open to being queried etc but I can’t work out what actual type I need to use. I want to pass this object into the following code so that it can act on the various settings that were specified. The declaration of option_table is:

:- type option_table(OptionType) == map(OptionType, option_data).

But I have so far failed to make the mental connection between whatever is in OptionType and the fact that my options look like this:

:- pred short_option(char::in, option::out) is semidet.

short_option('h', help).
short_option('v', version).
short_option('w', code_wrap).
short_option('s', syntax_check).
short_option('t', target).
short_option('T', list_targets).
short_option('o', output).
short_option('p', packed).
short_option('e', error_mode).

I want to just call, from main(),

	do_command_line(FileNames, Options, !IO),

But I don’t know what type to make `Options`.

Thank you.
Sean

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20210424/178404e0/attachment.html>


More information about the users mailing list