<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I have a working getopt configuration and, to cut a long story short, is it possible to restrict the values that an option can take or not ?<div class=""><br class=""></div><div class="">I have an option that specifies the error output mode thus,</div><div class=""><br class=""></div><div class=""><br class=""> short_option('e', error_mode).<br class=""> long_option("errormode", error_mode).</div><div class=""> option_defaults(error_mode, maybe_string(no)).<br class=""></div><div class=""><br class=""></div><div class="">Currently if I pass a value such as `—errormode blah` then it comes through as that string. The permissible values for this are one of ‘plain’, ’simple’, ‘json’ or ‘xml’… I would like to know how I can reject anything else, and maybe be case indifferent at the same time?</div><div class=""><br class=""></div><div class="">Is it a ’special handler’ that I need ? The issure has arisen because I currently implemtned a predicate to extract and return an error formor based on the string value, the code is is this:</div><div class=""><br class=""></div><div class=""><br class=""></div>:- pred get_error_format(felt_options::in, error_format::out) is semidet.<br class=""><br class=""><div class="">get_error_format(Options, F) :-<br class=""> (<br class=""> yes(Mode) = getopt.lookup_maybe_string_option(Options, options.error_mode)<br class=""> -><br class=""> string.to_lower(Mode, Modei),<br class=""> (<br class=""> "plain" = Modei, F = plain<br class=""> ;<br class=""> "simple" = Modei, F = simple<br class=""> ;<br class=""> "json" = Modei, F = json<br class=""> ;<br class=""> "xml" = Modei, F = xml<br class=""> )<br class=""> ;<br class=""> F = options.plain<br class=""> ).<br class=""><br class=""></div><div class=""><br class=""></div><div class="">but I stared fighting the det/semidet/multi argument with the compiler and it made me realise that, really, I should be limiting the strings I allowed through at that point. Is that a correct conclusion to have drawn?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Essentially I don’t want to the application to start of the command line contains junk.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Sean.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div style="color: rgb(51, 51, 51); background-color: rgb(249, 246, 241); font-family: "Courier, monospace, Dank Mono, Menlo, Monaco", Menlo, Monaco, "Courier New", monospace; font-size: 13px; line-height: 20px; white-space: pre;" class=""><div class=""></div></div></blockquote></div></body></html>