Permalink
Browse files

[enhance] serverArg, baseArg: made summary optional in write_simple_m…

…anpage, added default values
  • Loading branch information...
1 parent ad1c0cd commit 4a764573a700d6f03a23dc93517cd6d2b986146a Mathieu Baudet committed Dec 19, 2011
Showing with 13 additions and 8 deletions.
  1. +7 −4 libbase/baseArg.ml
  2. +1 −1 libbase/baseArg.mli
  3. +4 −2 libruntime/serverArg.ml
  4. +1 −1 libruntime/serverArg.mli
View
11 libbase/baseArg.ml
@@ -152,12 +152,15 @@ let write_simple_manpage
~cmdname ~section
?(centerfooter=(date_manpage ()))
?(leftfooter="") ?(centerheader="")
- ~summary ?synopsis ?description ?options ?(other=[])
+ ?(summary="") ?(synopsis="") ?(description="") ?options ?(other=[])
file =
Printf.fprintf file ".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n" cmdname (string_of_int section) centerfooter leftfooter centerheader;
- Printf.fprintf file ".SH NAME\n%s \\- %s\n" cmdname summary;
- begin match synopsis with None -> ()| Some(text) -> Printf.fprintf file ".SH SYNOPSIS\n%s\n" text end;
- begin match description with None -> ()| Some(text) -> Printf.fprintf file ".SH DESCRIPTION\n%s\n" text end;
+ if summary <> "" then
+ Printf.fprintf file ".SH NAME\n%s \\- %s\n" cmdname summary
+ else
+ Printf.fprintf file ".SH NAME\n%s\n" cmdname;
+ if synopsis <> "" then Printf.fprintf file ".SH SYNOPSIS\n%s\n" synopsis;
+ if description <> "" then Printf.fprintf file ".SH DESCRIPTION\n%s\n" description;
begin match options with None -> () | Some(speclist) -> begin
Printf.fprintf file ".SH OPTIONS\n";
List.iter (print_spec file) (add_help speclist);
View
2 libbase/baseArg.mli
@@ -66,7 +66,7 @@ val write_simple_manpage :
?centerfooter:string ->
?leftfooter:string ->
?centerheader:string ->
- summary:string ->
+ ?summary:string ->
?synopsis:string ->
?description:string ->
?options:(string * spec * string) list ->
View
6 libruntime/serverArg.ml
@@ -241,12 +241,14 @@ let doc_string title speclist =
speclist;
Format.flush_str_formatter ()
+(** write a simple manpage from serverArg specs *)
+(* CAVEAT: unfortunately many Opa programs install _several_ arg parsers by top-level side effects. This function should be generalized to allow several sections of options to reflect this fact. *)
let write_simple_manpage
?(nohelp=false)
~cmdname ~section
?centerfooter
?leftfooter ?centerheader
- ~summary ?synopsis ?description ?options ?(other=[])
+ ?summary ?synopsis ?description ?options ?(other=[])
file
=
let print_spec buf (names,_,params_doc,doc) =
@@ -270,7 +272,7 @@ let write_simple_manpage
~cmdname ~section
?centerfooter
?leftfooter ?centerheader
- ~summary ?synopsis ?description ~other:(match options_str with None -> other | Some(str) -> ("OPTIONS", str)::other)
+ ?summary ?synopsis ?description ~other:(match options_str with None -> other | Some(str) -> ("OPTIONS", str)::other)
file
let make_parser ?(final=false) ?(nohelp=false) title speclist acc0 args0 =
View
2 libruntime/serverArg.mli
@@ -169,7 +169,7 @@ val write_simple_manpage :
?centerfooter:string ->
?leftfooter:string ->
?centerheader:string ->
- summary:string ->
+ ?summary:string ->
?synopsis:string ->
?description:string ->
?options:'a arg_parser list ->

0 comments on commit 4a76457

Please sign in to comment.