Displaying 10 results from an estimated 10 matches for "parse_argv".
Did you mean:
parse_args
2016 Jul 11
0
Re: [PATCH v2] OCaml tools: add and use a Getopt module
...ady -- nothing to do. */
> + break;
> +
> + case 'h':
> + show_help (specsv, usage_msgv);
> + break;
Is this right? Several commands (eg. virt-df) take a -h option which
isn't for help.
The new code seems to be GC-safe as far as I can tell.
> +let parse_argv argv specs ?anon_fun usage_msg =
> + (* Sanity check the input *)
> + let validate_key key =
> + if String.length key == 0 || key == "-" || key == "--"
> + || key.[0] != '-' then
> + raise (Invalid_argument (sprintf "invalid option key...
2016 Jul 11
2
[PATCH v2] OCaml tools: add and use a Getopt module
...= Wosize_val (keysv);
+
+ assert (len != 0);
+
+ for (j = 0; j < len; ++j) {
+ const char *key = String_val (Field (keysv, j));
+ size_t key_len = strlen (key);
+ int has_arg = 0;
+
+ /* We assume that the key is valid, with the checks done in the
+ * OCaml Getopt.parse_argv. */
+ ++key;
+ if (key[0] == '-')
+ ++key;
+
+ switch (Tag_val (actionv)) {
+ case 0: /* Unit of (unit -> unit) */
+ case 1: /* Set of bool ref */
+ case 2: /* Clear of bool ref */
+ has_arg = 0;
+ break;
+
+ case 3: /* String o...
2016 Jun 24
2
[PATCH] RFC: OCaml tools: add and use a Getopt module
...string list
+type doc = string
+type usage_msg = string
+type anon_fun = (string -> unit)
+type c_keys = string array
+
+external getopt_parse : string array -> (c_keys * spec * doc) array -> ?anon_fun:anon_fun -> usage_msg -> unit = "guestfs_int_mllib_getopt_parse"
+
+let parse_argv argv specs ?anon_fun usage_msg =
+ let specs = specs @ [
+ (* Handled internally by getopt_parse. *)
+ [ "-h"; "-help"; "--help" ], Unit (fun () -> ()), s_"Display brief help";
+ ] in
+ let specs = List.map (
+ fun (keys, spec, doc) ->
+...
2016 Jul 13
3
[PATCH v3 1/2] OCaml tools: add and use a Getopt module
...= Wosize_val (keysv);
+
+ assert (len != 0);
+
+ for (j = 0; j < len; ++j) {
+ const char *key = String_val (Field (keysv, j));
+ size_t key_len = strlen (key);
+ int has_arg = 0;
+
+ /* We assume that the key is valid, with the checks done in the
+ * OCaml Getopt.parse_argv. */
+ ++key;
+ if (key[0] == '-')
+ ++key;
+
+ switch (Tag_val (actionv)) {
+ case 0: /* Unit of (unit -> unit) */
+ case 1: /* Set of bool ref */
+ case 2: /* Clear of bool ref */
+ has_arg = 0;
+ break;
+
+ case 3: /* String o...
2016 Jun 27
0
Re: [PATCH] RFC: OCaml tools: add and use a Getopt module
...; +type usage_msg = string
> +type anon_fun = (string -> unit)
> +type c_keys = string array
> +
> +external getopt_parse : string array -> (c_keys * spec * doc) array -> ?anon_fun:anon_fun -> usage_msg -> unit = "guestfs_int_mllib_getopt_parse"
> +
> +let parse_argv argv specs ?anon_fun usage_msg =
I feel this function could do some sanity checking on the inputs,
especially the keys (but see my comment below). If the sanity check
fails, it should either assert or failwith, but definitely not
continue.
> + let specs = specs @ [
> + (* Handled inter...
2016 Jul 15
5
[PATCH 0/3] mllib: Various fixes and changes to Getopt module.
The second patch is obviously not complete yet - for discussion only.
Rich.
2016 Jul 18
0
[PATCH v2 2/3] mllib: Use L"..." and S '...' for long and short options.
...tion_description;
+ [ L"long-options" ], Unit (display_long_options t),
+ hidden_option_description;
+ [ L"help" ], Unit (show_help t), s_"Display brief help";
+ ] in
+ t.specs <- added_options @ specs;
t
let parse_argv t argv =
let specs = List.map (
fun (keys, spec, doc) ->
- Array.of_list keys, spec, doc
+ Array.of_list (List.map string_of_option_name keys), spec, doc
) t.specs in
let specs = Array.of_list specs in
getopt_parse argv specs ?anon_fun:t.anon_fun t.usage_msg
diff --git...
2016 Jul 18
4
[PATCH v2 0/3] mllib: Various fixes and changes to Getopt module.
v1 -> v2:
- Further fixes to Getopt int parsing.
- Completed the L/S changes.
- Fixed the test suite so it passes now. Also we don't need the
special-case tests for 64 bit arch.
Rich.
2016 Jul 18
3
[PATCH v4 0/2] mllib: Various fixes and changes to Getopt module.
v3 -> v4:
- Pushed the first patch upstream since it was ACKed.
- Prevent use of M except for the special virt-v2v options.
- Sort the options after added --help etc.
- Make corresponding fixes to the tests.
Rich.
2016 Jul 18
4
[PATCH v3 0/3] mllib: Various fixes and changes to Getopt module.
v2 -> v3:
- Add M variant and test it.
Rich.