From dfce2e84d2de83579e2697d12b80d45b74290ecc Mon Sep 17 00:00:00 2001 From: David Udelson Date: Sat, 18 Mar 2017 01:40:52 +0900 Subject: [PATCH] Add irminconfig man page --- bin/ir_cli.ml | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/bin/ir_cli.ml b/bin/ir_cli.ml index 23e81156cd..ca3b9e3049 100644 --- a/bin/ir_cli.ml +++ b/bin/ir_cli.ml @@ -482,6 +482,35 @@ let dot = { Term.(mk dot $ store $ basename $ depth $ no_dot_call $ full); } +let irminconfig_man = + let version_string = Printf.sprintf "Irmin %s" Irmin.version in + ("irminconfig", 5, "", version_string, "Irmin Manual"), [ + `S Manpage.s_name; + `P "irminconfig - Specify certain command-line options to save on typing"; + + `S Manpage.s_synopsis; + `P ".irminconfig"; + + `S Manpage.s_description; + `P "An $(b,irminconfig) file lets the user specify repetitve command-line options \ + in a text file. The $(b,irminconfig) file is only read if it is found in \ + the current working directory. Every line is of the form $(i,key)=$(i,value), \ + where $(i,key) is one of the following: $(b,contents), $(b,store), $(b,branch), \ + $(b,root), $(b,bare), $(b,head), or $(b,uri). These correspond to the irmin \ + options of the same names."; + + `S "NOTES"; + `P "When specifying a value for the $(b,contents) or $(b,store) options, the \ + shortest unique substring starting from index 0 is sufficient. For example, \ + \"store=g\" is equivalent to \"store=git\"."; + + `S Manpage.s_examples; + `P "Here is an example $(b,irminconfig) for accessing a local http irmin store. This \ + $(b,irminconfig) prevents the user from having to specify the $(b,store) and $(b,uri) \ + options for every command."; + `Pre " \\$ cat .irminconfig\n store=http\n uri=http://127.0.0.1:8080"; + ] @ help_sections + (* HELP *) let help = { name = "help"; @@ -497,11 +526,13 @@ let help = { let help man_format cmds topic = match topic with | None -> `Help (`Pager, None) | Some topic -> - let topics = "topics" :: cmds in - let conv, _ = Arg.enum (List.rev_map (fun s -> (s, s)) topics) in + let topics = "irminconfig" :: cmds in + let conv, _ = Arg.enum (List.rev_map (fun s -> (s, s)) ("topics" :: topics)) in match conv topic with | `Error e -> `Error (false, e) - | `Ok t when t = "topics" -> List.iter print_endline cmds; `Ok () + | `Ok t when t = "topics" -> List.iter print_endline topics; `Ok () + | `Ok t when t = "irminconfig" -> + `Ok (Cmdliner.Manpage.print man_format Format.std_formatter irminconfig_man) | `Ok t -> `Help (man_format, Some t) in Term.(ret (mk help $Term.man_format $Term.choice_names $topic)) }