Last change
on this file since 59 was 32, checked in by fox, 2 years ago |
Use txt.conf:Authors for txt-new. Don't use Draft in filename
|
File size:
1.1 KB
|
Rev | Line | |
---|
[3] | 1 | open Logarion
|
---|
| 2 | open Cmdliner
|
---|
| 3 |
|
---|
| 4 | let new_txt title topics_opt interactive =
|
---|
[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 | if interactive then (Sys.command ("$EDITOR " ^ filepath) |> ignore);
|
---|
| 14 | print_endline filepath
|
---|
[3] | 15 |
|
---|
| 16 | let term =
|
---|
| 17 | let title = Arg.(value & pos 0 string "" & info []
|
---|
| 18 | ~docv:"title" ~doc:"Title for new article") in
|
---|
| 19 | let topics= Arg.(value & opt (some string) None & info ["t"; "topics"]
|
---|
| 20 | ~docv:"comma-separated topics" ~doc:"Topics for new article") in
|
---|
| 21 | let inter = Arg.(value & flag & info ["i"; "interactive"]
|
---|
| 22 | ~doc:"Prompts through the steps of creation") in
|
---|
| 23 | Term.(const new_txt $ title $ topics $ inter), Term.info "new"
|
---|
| 24 | ~doc:"create a new article" ~man:[ `S "DESCRIPTION";
|
---|
| 25 | `P "Create a new article, with title 'Draft' when none provided"]
|
---|
Note:
See
TracBrowser
for help on using the repository browser.