- Timestamp:
- Nov 19, 2022, 11:37:52 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/new.ml
r3 r32 3 3 4 4 let new_txt title topics_opt interactive = 5 let t = match title with "" -> "Draft" | _ -> titlein6 let authors = Person.Set.of_string ( Sys.getenv "USER") in7 let text = { (Text.blank ()) with title = t; authors }in8 let text = try Text.with_str_set text "Topics" (Option.get topics_opt)9 with _ ->text in5 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 10 match File_store.with_text text with 11 11 | Error s -> prerr_endline s 12 12 | 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 17 15 18 16 let term = -
trunk/lib/file_store.ml
r21 r32 125 125 126 126 let id_filename repo extension text = 127 let basename = Text.alias textin128 let candidate = Filename.concat repo (text.id ^ "." ^ basename^ extension) in127 let description = match Text.alias text with "" -> "" | x -> "." ^ x in 128 let candidate = Filename.concat repo (text.id ^ description ^ extension) in 129 129 if Sys.file_exists candidate then Error "Name clash, try again" else Ok candidate 130 130
Note:
See TracChangeset
for help on using the changeset viewer.