source: code/trunk/cli/new.ml@ 72

Last change on this file since 72 was 70, checked in by Izuru Yakumo, 8 months ago

What is the point of --interactive if it throws you into a text editor, anyway?

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

File size: 1.1 KB
RevLine 
[3]1open Logarion
[66]2open Cmdliner
[3]3
[70]4let new_txt title topics_opt =
[32]5 let kv = Logarion.File_store.of_kv_file () in
6 let authors = Person.Set.of_string (try Logarion.Store.KV.find "Authors" kv
7 with Not_found -> Sys.getenv "USER") in
8 let text = { (Text.blank ()) with title; authors } in
9 let text = try Text.with_str_set text "Topics" (Option.get topics_opt) with _->text in
[3]10 match File_store.with_text text with
11 | Error s -> prerr_endline s
12 | Ok (filepath, _note) ->
[32]13 print_endline filepath
[3]14
[66]15let title = Arg.(value & pos 0 string "" & info [] ~docv: "title" ~doc: "Title for new article")
16let topics = Arg.(value & opt (some string) None & info ["t"; "topics"] ~docv: "Comma-separated topics" ~doc: "Topics for new article")
17
[70]18let new_t = Term.(const new_txt $ title $ topics)
[66]19
20let cmd =
21 let doc = "Create a new article" in
22 let man = [
23 `S Manpage.s_description;
[69]24 `P "Create a new article";
[68]25 `S Manpage.s_environment;
[70]26 `P "USER - The login name of the user, used if the Authors field is blank" ]
[66]27 in
[69]28 let info = Cmd.info "new" ~doc ~man in
[66]29 Cmd.v info new_t
Note: See TracBrowser for help on using the repository browser.