1
1
let version = Version. version
2
2
3
- type cliCommand = Add of string | Clean | NoOp | Rm of string list
3
+ type cliCommand = Add of string | NoOp
4
4
5
5
let executeCliCommand ~printUsageAndExit cliCommand =
6
6
match cliCommand with
@@ -18,44 +18,7 @@ let executeCliCommand ~printUsageAndExit cliCommand =
18
18
if ! Debug. basic then Log_. item " Add %s %s\n " cmt mlast;
19
19
cmt |> GenTypeMain. processCmtFile ~config ;
20
20
exit 0
21
- | Clean ->
22
- let config = Paths. readConfig ~namespace: None in
23
- let sourceDirs = ModuleResolver. readSourceDirs ~config in
24
- if ! Debug. basic then
25
- Log_. item " Clean %d dirs\n " (sourceDirs.dirs |> List. length);
26
- let count = ref 0 in
27
- sourceDirs.dirs
28
- |> List. iter (fun dir ->
29
- let files = Sys. readdir dir in
30
- files
31
- |> Array. iter (fun file ->
32
- if
33
- Filename. check_suffix file " .re"
34
- || Filename. check_suffix file " .res"
35
- then
36
- let extension = EmitType. outputFileSuffix ~config in
37
- let generated =
38
- Filename. concat dir
39
- ((file |> Filename. chop_extension) ^ extension)
40
- in
41
- if Sys. file_exists generated then (
42
- Unix. unlink generated;
43
- incr count)));
44
- if ! Debug. basic then Log_. item " Cleaned %d files\n " ! count;
45
- exit 0
46
21
| NoOp -> printUsageAndExit ()
47
- | Rm l ->
48
- let removeOne s =
49
- let cmtAbsolutePath = s in
50
- (* somehow the CMT hook is passing an absolute path here *)
51
- let cmt = cmtAbsolutePath |> Paths. relativePathFromBsLib in
52
- let config = Paths. readConfig ~namespace: (cmt |> Paths. findNameSpace) in
53
- let outputFile = cmt |> Paths. getOutputFile ~config in
54
- if ! Debug. basic then Log_. item " Remove %s\n " cmt;
55
- if Sys. file_exists outputFile then Unix. unlink outputFile
56
- in
57
- l |> List. rev |> List. iter removeOne;
58
- exit 0
59
22
60
23
let cli () =
61
24
let cliCommand = ref NoOp in
@@ -71,23 +34,14 @@ let cli () =
71
34
if ! cliCommand <> NoOp then printUsageAndExit () ;
72
35
cliCommand := command
73
36
and setAdd s = Add s |> setCliCommand
74
- and setRm s = Rm s |> setCliCommand
75
- and setClean () = Clean |> setCliCommand
76
37
and speclist =
77
38
[
78
- (" -clean" , Arg. Unit setClean, " clean all the generated files" );
79
39
(" -cmt-add" , Arg. String setAdd, " compile a .cmt[i] file" );
80
- ( " -cmt-rm" ,
81
- Arg. String (fun s -> setRm [ s ]),
82
- " remove one or more .cmt[i] files" );
83
40
(" -version" , Arg. Unit versionAndExit, " show version information and exit" );
84
41
(" --version" , Arg. Unit versionAndExit, " show version information and exit" );
85
42
]
86
43
in
87
- let anonArg s =
88
- match ! cliCommand with
89
- | Rm l -> cliCommand := Rm (s :: l)
90
- | _ -> print_endline s
44
+ let anonArg s = print_endline s
91
45
in
92
46
Arg. parse speclist anonArg usage;
93
47
executeCliCommand ~print UsageAndExit ! cliCommand
0 commit comments