Skip to content

Commit

Permalink
Merge pull request #427 from dudelson/irminconfig-doc
Browse files Browse the repository at this point in the history
Add irminconfig man page
  • Loading branch information
samoht authored Mar 27, 2017
2 parents 25e8f08 + dfce2e8 commit 55b22dd
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions bin/ir_cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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))
}
Expand Down

0 comments on commit 55b22dd

Please sign in to comment.