Files
kosuzu/cli/file.ml
fox 787cba90fe - Removed 'txt init'
Format

- New B32 ID

Index

- New option: txt index --print
- Move scheme to peers
- Replace peer.*.conf files with index packed locations
  Instead of adding a URL to peers.*.conf, run `txt pull <url>`

Conversion

- Rewritten converters
- txt-convert looks for a .convert.conf containing `key: value` lines.
- Specifiable topic-roots from .convert.conf.
- Added `Topics:` key, with comma seperated topics.
	If set only those topics will appear in the main index and used as topic roots.
	Other topics will have sub-indices generated, but won't be listed in the main index.
- HTML converter header & footer options
- HTML-index renamed to HTM-index

Internal

- Change types: uuid:Uuid -> id:string
- File_store merges identical texts
- Use peer ID for store path, store peers' texts in .local/share/texts
- Simple URN resolution for converter
	Continue to next feed if parsing one fails
- Phasing-out Archive, replaced by improved packs
- Eliminate Bos, Cohttp, lwt, uri, tls, Re, Ptime, dependencies
- Lock version for Cmdliner, fix dune-project
- Optional resursive store
- Improve header_pack
- Fix recursive mkdir

git-svn-id: file:///srv/svn/repo/kosuzu/trunk@3 eb64cd80-c68d-6f47-b6a3-0ada418499da
2022-04-15 13:17:01 +00:00

40 lines
1.5 KiB
OCaml

let split_filetypes files =
let acc (dirs, files) x = if Sys.is_directory x
then (x::dirs, files) else (dirs, x::files) in
List.fold_left acc ([],[]) files
open Logarion
let file files =
let dirs, files = split_filetypes files in
let _link_as_named dir file = Unix.link file (Filename.concat dir file) in
let link_with_id dir file =
match File_store.to_text file with Error s -> prerr_endline s
| Ok t -> Unix.link file (Filename.concat dir (Text.short_id t^".txt")) in
let link = link_with_id in
List.iter (fun d -> List.iter (link d) files) dirs
let unfile files =
let dirs, files = split_filetypes files in
let unlink dir file = try Unix.unlink (Filename.concat dir file)
with Unix.(Unix_error(ENOENT,_,_))-> () in
List.iter (fun d -> List.iter (unlink d) files) dirs
open Cmdliner
let term =
let files = Arg.(value & pos_all string [] & info []
~docv:"text filenames and subdirectories") in
Term.(const file $ files), Term.info "file"
~doc:"file texts in subdirectories"
~man:[ `S "DESCRIPTION"; `P "Files all texts in parameter in every
directory in parameter, using hardlinks.
Use it to create sub-repositories for sharing or converting" ]
let unfile_term =
let files = Arg.(value & pos_all string [] & info []
~docv:"text filenames and subdirectories") in
Term.(const unfile $ files), Term.info "unfile"
~doc:"unfile texts from subdirectories"
~man:[ `S "DESCRIPTION"; `P "unfile texts in parameter from
directories in parameter, by removing hardlinks" ]