Changeset 66 in code for trunk/cli/index.ml


Ignore:
Timestamp:
Aug 21, 2024, 1:37:05 AM (8 months ago)
Author:
yakumo.izuru
Message:

Migrate the codebase to the latest revision of Cmdliner

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/index.ml

    r65 r66  
    6868        index { dir; index_path; pck = Header_pack.of_kv kv }
    6969
    70 open Ocmd
    71 let term =
    72         let print= Arg.(value & flag & info ["print"] ~doc:"print info") in
    73         let title= Arg.(value & opt ~vopt:(Some "") (some string) None & info ["t"; "title"]
    74                 ~docv:"string" ~doc:"Title for index") in
    75         let auth = Arg.(value & opt ~vopt:(Some "") (some string) None & info ["a"; "authors"]
    76                 ~docv:"comma-separated names" ~doc:"Index authors") in
    77         let locs = Arg.(value & opt ~vopt:(Some "") (some string) None & info ["l"; "locations"]
    78                 ~docv:"comma-separated URLs" ~doc:"repository URLs") in
    79         let peers= Arg.(value & opt ~vopt:(Some "") (some string) None & info ["p"; "peers"]
    80                 ~docv:"comma-separated URLs" ~doc:"URLs to other known text repositories") in
    81         let dir  = Arg.(value & pos 0 string "." & info []
    82                 ~docv:"directory to index") in
    83         let doc = "Generate an index.pck for texts in a directory" in
    84         Term.(const load $ dir $ print $ title $ auth $ locs $ peers),
    85                 Term.info "index" ~doc
    86                         ~man:[ `S "DESCRIPTION"; `Pre "An index contains:\n
    87 * an info section with: title for the index, the authors, locations (URLs) the texts can be access\n
    88 * listing of texts with: ID, date, title, authors, topics\n
    89 * list of other text repositories (peers)\n\n
    90 MessagePack format. <msgpack.org>"  ]
     70open Cmdliner
     71let print = Arg.(value & flag & info ["print"] ~doc: "Print info")
     72let title = Arg.(value & opt ~vopt:(Some "") (some string) None & info ["t"; "title"] ~docv: "string" ~doc: "Title for index")
     73let auth = Arg.(value & opt ~vopt:(Some "") (some string) None & info ["a"; "authors"] ~docv: "Comma-separated names" ~doc: "Index authors")
     74let locs = Arg.(value & opt ~vopt:(Some "") (some string) None & info ["l"; "location"] ~docv: "Comma-separated URLs" ~doc: "Repository URLs")
     75let peers = Arg.(value & opt ~vopt:(Some "") (some string) None & info ["p"; "peers"] ~docv: "Comma-separated URLs" ~doc: "URLs to other known text repositories")
     76let dir = Arg.(value & pos 0 string "." & info [] ~docv: "Directory to index")
    9177
     78let index_t = Term.(const load $ dir $ print $ title $ auth $ locs $ peers)
     79
     80let cmd =
     81  let doc = "Generate an index.pck for texts in a directory" in
     82  let man = [
     83      `S Manpage.s_description;
     84      `P "An index contains:\n";
     85      `P "* n info section with: title for the index, the authors, locations (URLs) the texts can be accessed.";
     86      `P "* listing of texts with: ID, date, title, authors, topics.";
     87      `P "* list of other text repositories (peers)";
     88      `S Manpage.s_see_also;
     89      `P "MessagePack format. https://msgpack.org" ] in
     90  let info = Cmd.info "index" ~version:"%%VERSION%%" ~doc ~man in
     91  Cmd.v info index_t
Note: See TracChangeset for help on using the changeset viewer.