Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 60 lines (52 sloc) 2.581 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 ##extern-type CommandLine.private.native.state('a) = 'a ServerArg.state
19 (*extern-type CommandLine.private.native.parser('a) = 'a -> ServerArg.arg_parser('a)*)
20 ##extern-type CommandLine.private.native.args_parser('a) = 'a ServerArg.arg_parser
21 (*
22 extern-type [opaname] CommandLine.private.native.category_parser('a) = 'a ServerArg.param_parser
23 register make_arg_parser: caml_list(string),string,string, ('a, string -> option('a)) -> CommandLine.private.native.arg_parser('a)
24 let make_arg_parser names param_doc doc effect =
25 let f' init = ServerArg.func_opt ServerArg.string effect init in
26 let g' = ServerArg.fold f' in
27 (names, g', param_doc, doc)
28 *)
29 ##register filter: string, caml_list(CommandLine.private.native.args_parser('a)), 'a -> 'a
30 let filter topic args init =
31 let my_parser = ServerArg.make_parser topic args in
32 ServerArg.filter init my_parser
33
34 (*
35 Used for anonymous arguments.
36 If the function returns {none} the argument is kept
37 *)
38 ##register anonymous_filter: ('a, string -> option('a)), 'a -> 'a
39 let anonymous_filter func init =
40 let param_parser = ServerArg.func_opt ServerArg.anystring func in
41 let param_parser = ServerArg.fold_all param_parser in
42 ServerArg.filter init param_parser
43
44 ##register no_more_params : 'a -> CommandLine.private.native.state('a)
45 ##register more_params: 'a -> CommandLine.private.native.state('a)
46 ##register maybe_params: 'a -> CommandLine.private.native.state('a)
47 let no_more_params x = ServerArg.No_more_params x
48 let more_params x = ServerArg.More_params x
49 let maybe_params x = ServerArg.Maybe_params x
50
51 ##register make: \
52 caml_list(string), \
53 string, \
54 string, \
55 ('a -> CommandLine.private.native.state('a)), \
56 ('a, string -> option(CommandLine.private.native.state('a))) -> \
57 CommandLine.private.native.args_parser('a)
58 let make names param_doc doc initialize step =
59 ServerArg.make_arg_parser ~names ~param_doc ~doc ~initialize ~step
Something went wrong with that request. Please try again.