Last change
on this file since 74 was 73, checked in by Izuru Yakumo, 8 months ago |
Because sweet girls are the best, officially rebranding Logarion to Kosuzu
Signed-off-by: Izuru Yakumo <yakumo.izuru@…>
|
File size:
1.1 KB
|
Rev | Line | |
---|
[73] | 1 | open Kosuzu
|
---|
| 2 | open Cmdliner
|
---|
| 3 |
|
---|
| 4 | let new_txt title topics_opt =
|
---|
| 5 | let kv = Kosuzu.File_store.of_kv_file () in
|
---|
| 6 | let authors = Person.Set.of_string (try Kosuzu.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 |
|
---|
| 15 | let title = Arg.(value & pos 0 string "" & info [] ~docv: "title" ~doc: "Title for new article")
|
---|
| 16 | let topics = Arg.(value & opt (some string) None & info ["t"; "topics"] ~docv: "Comma-separated topics" ~doc: "Topics for new article")
|
---|
| 17 |
|
---|
| 18 | let new_t = Term.(const new_txt $ title $ topics)
|
---|
| 19 |
|
---|
| 20 | let 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.