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

Last change on this file since 70 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
Line 
1open Logarion
2open Cmdliner
3
4let new_txt title topics_opt =
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
10 match File_store.with_text text with
11 | Error s -> prerr_endline s
12 | Ok (filepath, _note) ->
13 print_endline filepath
14
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
18let new_t = Term.(const new_txt $ title $ topics)
19
20let cmd =
21 let doc = "Create a new article" in
22 let man = [
23 `S Manpage.s_description;
24 `P "Create a new article";
25 `S Manpage.s_environment;
26 `P "USER - The login name of the user, used if the Authors field is blank" ]
27 in
28 let info = Cmd.info "new" ~doc ~man in
29 Cmd.v info new_t
Note: See TracBrowser for help on using the repository browser.