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

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

txt new no longer sets default titles, remove %%VERSION%% from all subcommands (as they're pulled from txt.ml)

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

File size: 1.3 KB
Line 
1open Logarion
2open Cmdliner
3
4let new_txt title topics_opt interactive =
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 if interactive then (Sys.command ("$EDITOR " ^ filepath) |> ignore);
14 print_endline filepath
15
16let title = Arg.(value & pos 0 string "" & info [] ~docv: "title" ~doc: "Title for new article")
17let topics = Arg.(value & opt (some string) None & info ["t"; "topics"] ~docv: "Comma-separated topics" ~doc: "Topics for new article")
18let inter = Arg.(value & flag & info ["i"; "interactive"] ~doc: "Prompt through the steps of creation")
19
20let new_t = Term.(const new_txt $ title $ topics $ inter)
21
22let cmd =
23 let doc = "Create a new article" in
24 let man = [
25 `S Manpage.s_description;
26 `P "Create a new article";
27 `S Manpage.s_environment;
28 `P "USER - The login name of the user, used if the Authors field is blank";
29 `P "EDITOR - Default editor name" ]
30 in
31 let info = Cmd.info "new" ~doc ~man in
32 Cmd.v info new_t
Note: See TracBrowser for help on using the repository browser.