Something went wrong. Try again.
Shells in OCaml
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334open Cmdliner
let paths = let doc = "A pathname of an input file. If no file operands are specified, the \ standard input shall be used. If a file is '-', the cat utility shall \ read from the standard input at that point in the sequence. The cat \ utility shall not close and reopen standard input when it is referenced \ in this way, but shall accept multiple occurrences of '-' as a file \ operand." in Arg.(value & pos_all string [] & info [] ~doc)
let term env = let make paths = match paths with | [] -> Eio.Flow.copy env#stdin env#stdout | _ -> List.iter (fun path -> Eio.Path.(with_open_in (env#fs / path)) @@ fun src -> Eio.Flow.copy src env#stdout) paths in let term = Term.(const make $ paths) in let info = let doc = "The cat utility shall read files in sequence and shall write their \ contents to the standard output in the same sequence." in Cmd.info "cat" ~doc in Cmd.v info term