Skip to content

Commit

Permalink
[enhance] serverArg, baseArg: made summary optional in write_simple_m…
Browse files Browse the repository at this point in the history
…anpage, added default values
  • Loading branch information
Mathieu Baudet committed Dec 20, 2011
1 parent ad1c0cd commit 4a76457
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
11 changes: 7 additions & 4 deletions libbase/baseArg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libbase/baseArg.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
6 changes: 4 additions & 2 deletions libruntime/serverArg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand All @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion libruntime/serverArg.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down

0 comments on commit 4a76457

Please sign in to comment.