Source file commandPreSession.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
open Ezcmd.TYPES
open EzConfig.OP
open Ez_file.V1
let cmd_name = "pre-session"
let action args =
Misc.log_cmd ~nvo:None cmd_name args ;
Misc.global_log ~nvo:None "Session started";
begin
if !!Config.enabled then
if Misc.not_this_switch () then
Printf.printf "%s disabled in this switch\n%!" Globals.command
else
Printf.printf "%s [ creation: %b, sharing: %b ]\n%!" Globals.command
!!Config.create_enabled !!Config.share_enabled
else
Printf.printf "%s disabled\n%!" Globals.command
end;
let filename = Globals.opambin_session_msg_file () in
if Sys.file_exists filename then
Sys.remove filename
else
EzFile.make_dir ~p:true (Filename.dirname filename)
let cmd =
let args = ref [] in
Arg.{
cmd_name ;
cmd_action = (fun () -> action !args) ;
cmd_args = [
[], Anons (fun list -> args := list),
Ezcmd.info "args"
];
cmd_man = [];
cmd_doc = "(opam hook) Start Session";
}