Changeset 32 in code


Ignore:
Timestamp:
Nov 19, 2022, 11:37:52 AM (2 years ago)
Author:
fox
Message:

Use txt.conf:Authors for txt-new. Don't use Draft in filename

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/new.ml

    r3 r32  
    33
    44let new_txt title topics_opt interactive =
    5         let t = match title with "" -> "Draft" | _ -> title in
    6         let authors = Person.Set.of_string (Sys.getenv "USER") in
    7         let text = { (Text.blank ()) with title = t; authors } in
    8         let text = try Text.with_str_set text "Topics" (Option.get topics_opt)
    9                 with _ -> text in
     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
    1010        match File_store.with_text text with
    1111        | Error s -> prerr_endline s
    1212        | Ok (filepath, _note) ->
    13                 if not interactive then print_endline filepath
    14                 else
    15                         (print_endline @@ "Created: " ^ filepath;
    16                         Sys.command ("$EDITOR " ^ filepath) |> ignore)
     13                if interactive then (Sys.command ("$EDITOR " ^ filepath) |> ignore);
     14                print_endline filepath
    1715
    1816let term =
  • trunk/lib/file_store.ml

    r21 r32  
    125125
    126126let id_filename repo extension text =
    127         let basename = Text.alias text in
    128         let candidate = Filename.concat repo (text.id ^ "." ^ basename ^ extension) in
     127        let description = match Text.alias text with "" -> "" | x -> "." ^ x in
     128        let candidate = Filename.concat repo (text.id ^ description ^ extension) in
    129129        if Sys.file_exists candidate then Error "Name clash, try again" else Ok candidate
    130130
Note: See TracChangeset for help on using the changeset viewer.