Overview  Index  Help 
SMLDoc

GETOPT

All Known Implementing Modules:

GetOptMain.G


signature GETOPT =
sig
  type 'a opt_descr =
       {short : string, long : string list, desc : 'a arg_descr, help : string}
  datatype 'a arg_order = RequireOrder | Permute | ReturnInOrder of string -> 'a
  datatype 'a arg_descr =
           NoArg of 'a
         | ReqArg of (string -> 'a) * string
         | OptArg of (string option -> 'a) * string
  val usageInfo : string -> 'a opt_descr list -> string
  val getOpt
      : 'a arg_order ->
          'a opt_descr list ->
            string list -> 'a list * string list * string list
end

A SML port of GNU's getopt library. This port is derived from Sven Panne's implementation of the getopt library in Haskell The following comments are lifted from Sven's code:

Two rather obscure features are missing: The Bash 2.0 non-option hack (if you don't already know it, you probably don't want to hear about it...) and the recognition of long options with a single dash (e.g. '-help' is recognised as '--help', as long as there is no short option 'h').

Other differences between GNU's getopt and this implementation:

  • To enforce a coherent description of options and arguments, there are explanation fields in the option/argument descriptor.
  • Error messages are now more informative, but no longer POSIX compliant... :-(

Author:
(c) 1998 Bell Labs, Lucent Technologies.
Version:
$Id: SigGETOPT.html,v 1.9 2007/02/17 07:01:57 kiyoshiy Exp $

 
Type detail

opt_descr

type 'a opt_descr =
     {short : string, long : string list, desc : 'a arg_descr, help : string}

 
Datatype detail

arg_order

datatype 'a arg_order = RequireOrder | Permute | ReturnInOrder of string -> 'a


arg_descr

datatype 'a arg_descr =
         NoArg of 'a
       | ReqArg of (string -> 'a) * string
       | OptArg of (string option -> 'a) * string

 
DataConstructor detail

RequireOrder

constructor RequireOrder : 'a arg_order


Permute

constructor Permute : 'a arg_order


ReturnInOrder

constructor ReturnInOrder : (string -> 'a) -> 'a arg_order


NoArg

constructor NoArg : 'a -> 'a arg_descr


ReqArg

constructor ReqArg : (string -> 'a) * string -> 'a arg_descr


OptArg

constructor OptArg : (string option -> 'a) * string -> 'a arg_descr

 
Value detail

usageInfo

val usageInfo : string -> 'a opt_descr list -> string


getOpt

val getOpt
    : 'a arg_order ->
        'a opt_descr list -> string list -> 'a list * string list * string list

 


Overview  Index  Help 
SMLDoc: Documentation generator for SML