search for: validate_key

Displaying 12 results from an estimated 12 matches for "validate_key".

2016 Jul 18
1
Re: [PATCH v2 2/3] mllib: Use L"..." and S '...' for long and short options.
On Monday, 18 July 2016 14:43:03 CEST Richard W.M. Jones wrote: > > > - let validate_key key = > > > - if String.length key == 0 || key == "-" || key == "--" > > > - || key.[0] != '-' then > > > - invalid_arg (sprintf "invalid option key: '%s'" key) > > > + let validate_key = function >...
2016 Jul 18
2
Re: [PATCH v2 2/3] mllib: Use L"..." and S '...' for long and short options.
...rote: > --- Note that this changes the way -foo options are handled: this basically makes them as --foo, but still working as -foo because getopt_long_only is used. IMHO either add a new M".." ([M]edium or [T]runcated or [D]ash or ...), or turn S to get a string instead. > - let validate_key key = > - if String.length key == 0 || key == "-" || key == "--" > - || key.[0] != '-' then > - invalid_arg (sprintf "invalid option key: '%s'" key) > + let validate_key = function > + | L"" -> invalid_arg &...
2016 Jul 18
0
Re: [PATCH v2 2/3] mllib: Use L"..." and S '...' for long and short options.
...".." ([M]edium or [T]runcated or > [D]ash or ...), or turn S to get a string instead. Do you mean only for the 'virt-v2v --help' output? I don't think there is any other place in the code where the M option would be handled differently from the L option. > > - let validate_key key = > > - if String.length key == 0 || key == "-" || key == "--" > > - || key.[0] != '-' then > > - invalid_arg (sprintf "invalid option key: '%s'" key) > > + let validate_key = function > > + | L"&...
2016 Jul 11
0
Re: [PATCH v2] OCaml tools: add and use a Getopt module
...ow_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: '%s'" key)) Whereever you've written 'raise (Invalid_argument ...)'...
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
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
0
[PATCH v2 2/3] mllib: Use L"..." and S '...' for long and short options.
...(String.lowercase (skip_dashes a)) (String.lowercase (skip_dashes b)) + let a = String.lowercase (string_of_option_name_no_dashes a) in + let b = String.lowercase (string_of_option_name_no_dashes b) in + compare a b let create specs ?anon_fun usage_msg = (* Sanity check the input *) - let validate_key key = - if String.length key == 0 || key == "-" || key == "--" - || key.[0] != '-' then - invalid_arg (sprintf "invalid option key: '%s'" key) + let validate_key = function + | L"" -> invalid_arg "Getopt spec: invalid...
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.
2016 Jul 11
2
[PATCH v2] OCaml tools: add and use a Getopt module
...> 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 = + (* 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: '%s'" key)) + in + + List.iter ( + fun (keys, spec, doc) -> + if keys == [] then +...
2016 Jul 18
4
[PATCH 1/3] mllib: Getopt: point to man page as additional help
On error, point also to the man page of the current tool in addition to '$TOOL --help'. --- mllib/getopt-c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mllib/getopt-c.c b/mllib/getopt-c.c index bf40f91..3efd5d3 100644 --- a/mllib/getopt-c.c +++ b/mllib/getopt-c.c @@ -69,8 +69,8 @@ cleanup_option_list (void *ptr) static void __attribute__((noreturn))
2016 Jul 13
3
[PATCH v3 1/2] OCaml tools: add and use a Getopt module
...p (i+1) + else i + in + let i = loop 0 in + if i = 0 then str + else String.sub str i (n-i) + +let compare_command_line_args a b = + compare (String.lowercase (skip_dashes a)) (String.lowercase (skip_dashes b)) + +let create specs ?anon_fun usage_msg = + (* Sanity check the input *) + let validate_key key = + if String.length key == 0 || key == "-" || key == "--" + || key.[0] != '-' then + invalid_arg (sprintf "invalid option key: '%s'" key) + in + + List.iter ( + fun (keys, spec, doc) -> + if keys == [] then + inval...