1module type S = sig
2 type config
3 (** A configuration *)
4
5 val config_term : config Cmdliner.Term.t
6 (** A cmdliner term for constructing a config *)
7
8 type action
9 (** An action to run *)
10
11 val action : action Repr.t
12 val action_of_command : string -> action
13
14 type entry
15
16 type ctx
17 (** A context that is not persisted, but is passed through each loop of the
18 shell *)
19
20 type error
21 (** Shell specific errors *)
22
23 val pp_error : error Fmt.t
24
25 val init :
26 _ Eio.Path.t ->
27 Eio_unix.Process.mgr_ty Eio_unix.Process.mgr ->
28 entry History.t ->
29 ctx
30 (** [init store] will be called before entering the shell loop. You may wish
31 to setup history completions etc. with LNoise. *)
32
33 val run :
34 config ->
35 stdout:Eio.Flow.sink_ty Eio.Flow.sink ->
36 Eio.Fs.dir_ty Eio.Path.t ->
37 _ Eio.Time.clock ->
38 Eio_unix.Process.mgr_ty Eio_unix.Process.mgr ->
39 entry History.t * ctx ->
40 action ->
41 ( entry History.t * ctx,
42 [ `Process of Eio.Process.error | `Shell of error ] )
43 result
44 (** [run history action] runs the action in [history]. Return a new [history]
45 that can be persisted *)
46
47 val prompt : Eio.Process.exit_status -> entry History.t -> string
48 (** [prompt previous_exit_code history] generates a prompt from the current
49 [history] *)
50end