Skip to content

Commit 2fed4e8

Browse files
committed
Remove unused CLI commands.
1 parent c2bc59e commit 2fed4e8

File tree

2 files changed

+675
-767
lines changed

2 files changed

+675
-767
lines changed

jscomp/gentype/GenType.ml

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let version = Version.version
22

3-
type cliCommand = Add of string | Clean | NoOp | Rm of string list
3+
type cliCommand = Add of string | NoOp
44

55
let executeCliCommand ~printUsageAndExit cliCommand =
66
match cliCommand with
@@ -18,44 +18,7 @@ let executeCliCommand ~printUsageAndExit cliCommand =
1818
if !Debug.basic then Log_.item "Add %s %s\n" cmt mlast;
1919
cmt |> GenTypeMain.processCmtFile ~config;
2020
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
4621
| 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
5922

6023
let cli () =
6124
let cliCommand = ref NoOp in
@@ -71,23 +34,14 @@ let cli () =
7134
if !cliCommand <> NoOp then printUsageAndExit ();
7235
cliCommand := command
7336
and setAdd s = Add s |> setCliCommand
74-
and setRm s = Rm s |> setCliCommand
75-
and setClean () = Clean |> setCliCommand
7637
and speclist =
7738
[
78-
("-clean", Arg.Unit setClean, "clean all the generated files");
7939
("-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" );
8340
("-version", Arg.Unit versionAndExit, "show version information and exit");
8441
("--version", Arg.Unit versionAndExit, "show version information and exit");
8542
]
8643
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
9145
in
9246
Arg.parse speclist anonArg usage;
9347
executeCliCommand ~printUsageAndExit !cliCommand

0 commit comments

Comments
 (0)