This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

1module History = struct 2 type t = string 3 4 let t = Repr.string 5 let merge = Irmin.Merge.default (Repr.option t) 6end 7 8module Pass = Shelter.Make (History) (Shelter_passthrough) 9module Main = Shelter.Make (Shelter_main.History) (Shelter_main) 10 11let home = Unix.getenv "HOME" 12 13let state_dir fs type' = 14 let path = Eio.Path.(fs / home / ".cache/shelter" / type') in 15 Eio.Path.mkdirs ~exists_ok:true ~perm:0o755 path; 16 path 17 18module Eventloop = struct 19 let run fn = 20 Eio_posix.run @@ fun env -> 21 Lwt_eio.with_event_loop ~clock:env#clock @@ fun _token -> fn env 22end 23 24(* Command Line *) 25open Cmdliner 26 27let cmd_file = 28 let doc = "Path to a file containing a series of commands." in 29 Arg.( 30 value 31 & opt (some file) None 32 & info [ "f"; "file" ] ~docv:"COMMAND_FILE" ~doc) 33 34let main = 35 let run config cmd_file = 36 Eventloop.run @@ fun env -> 37 let cmd_file = Option.map (Eio.Path.( / ) env#fs) cmd_file in 38 let dir = state_dir env#fs "shelter" in 39 let stdout = (env#stdout :> Eio.Flow.sink_ty Eio.Flow.sink) in 40 Main.main config ~stdout env#fs env#clock env#process_mgr dir cmd_file 41 in 42 let t = Term.(const run $ Shelter_main.config_term $ cmd_file) in 43 let man = 44 [ 45 `P 46 "Shelter is a shell session shim to help control uncertainty when \ 47 working from the terminal"; 48 ] 49 in 50 let doc = "Shelter: version-controlled shell sessions" in 51 let info = Cmd.info ~man ~doc "main" in 52 (Cmd.v info t, t, info) 53 54let passthrough = 55 let run config cmd_file = 56 Eventloop.run @@ fun env -> 57 let cmd_file = Option.map (Eio.Path.( / ) env#fs) cmd_file in 58 let dir = state_dir env#fs "passthrough" in 59 let stdout = (env#stdout :> Eio.Flow.sink_ty Eio.Flow.sink) in 60 Pass.main config ~stdout env#fs env#clock env#process_mgr dir cmd_file 61 in 62 let t = Term.(const run $ Shelter_passthrough.config_term $ cmd_file) in 63 let info = Cmd.info "passthrough" in 64 Cmd.v info t 65 66let extract_commands = 67 let run cmd_file = 68 Eventloop.run @@ fun env -> 69 let cmd_file = Eio.Path.( / ) env#fs (Option.get cmd_file) in 70 Shelter.Script.to_commands cmd_file |> List.iter (Fmt.pr "%s\n") 71 in 72 let t = Term.(const run $ cmd_file) in 73 let info = Cmd.info "extract" in 74 Cmd.v info t 75 76let cmds = 77 let cmd, term, info = main in 78 let cmds = [ cmd; passthrough; extract_commands ] in 79 Cmd.group ~default:term info cmds 80 81let () = 82 Fmt_tty.setup_std_outputs (); 83 exit (Cmd.eval cmds)