Skip to content

Commit 71e729e

Browse files
committed
tweaks
1 parent 8eadda9 commit 71e729e

File tree

3 files changed

+108
-129
lines changed

3 files changed

+108
-129
lines changed

jscomp/main/rescript_main.ml

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ let watch_mode = ref false
3030
let make_world = ref false
3131
let do_install = ref false
3232
let force_regenerate = ref false
33-
let bs_version_string = Bs_version.version
34-
let print_version_string () =
35-
print_string bs_version_string;
36-
print_newline ();
37-
exit 0
33+
3834
type spec = Bsb_arg.spec
3935

4036
let call_spec f : spec = Unit (Unit_call f )
@@ -115,17 +111,7 @@ let install_target () =
115111
if eid <> 0 then
116112
Bsb_unix.command_fatal_error install_command eid
117113

118-
let global_help () =
119-
print_string {|Available flags
120-
-v, -version display version number
121-
-h, -help display help
122-
Subcommands:
123-
build
124-
clean
125-
help
126-
Run rescript subcommand -h for more details, for example
127-
rescript build -h
128-
|}
114+
129115

130116
let build_subcommand ~start argv argv_len =
131117
let i = Ext_array.rfind_with_index argv Ext_string.equal separator in
@@ -243,23 +229,15 @@ let () =
243229
~per_proj_dir:Bsb_global_paths.cwd |> ignore;
244230
ninja_command_exit [||]
245231
end else
246-
247-
248-
249232
match argv.(1) with
250-
| "-version" | "-v"
251-
-> print_version_string ()
252-
| "-help" | "-h"
253-
-> global_help ()
254233
| "build" ->
255234
build_subcommand ~start:2 argv argv_len
256235
| "clean" ->
257236
clean_subcommand ~start:2 argv
258237
| "init" ->
259238
init_subcommand ~start:2 argv
260-
| "info" ->
239+
| "info" -> (* internal *)
261240
info_subcommand ~start:2 argv
262-
| "help" -> global_help ()
263241
| first_arg ->
264242
prerr_endline @@ "Unknown subcommand or flags: " ^ first_arg;
265243
exit 1

lib/4.06.1/rescript.ml

Lines changed: 66 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,3 @@
1-
module Bs_version : sig
2-
#1 "bs_version.mli"
3-
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
4-
*
5-
* This program is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU Lesser General Public License as published by
7-
* the Free Software Foundation, either version 3 of the License, or
8-
* (at your option) any later version.
9-
*
10-
* In addition to the permissions granted to you by the LGPL, you may combine
11-
* or link a "work that uses the Library" with a publicly distributed version
12-
* of this file to produce a combined library or application, then distribute
13-
* that combined work under the terms of your choosing, with no requirement
14-
* to comply with the obligations normally placed on you by section 4 of the
15-
* LGPL version 3 (or the corresponding section of a later version of the LGPL
16-
* should you choose to use a later version).
17-
*
18-
* This program is distributed in the hope that it will be useful,
19-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21-
* GNU Lesser General Public License for more details.
22-
*
23-
* You should have received a copy of the GNU Lesser General Public License
24-
* along with this program; if not, write to the Free Software
25-
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
26-
27-
val version : string
28-
29-
val header : string
30-
31-
val package_name : string ref
32-
end = struct
33-
#1 "bs_version.ml"
34-
35-
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
36-
*
37-
* This program is free software: you can redistribute it and/or modify
38-
* it under the terms of the GNU Lesser General Public License as published by
39-
* the Free Software Foundation, either version 3 of the License, or
40-
* (at your option) any later version.
41-
*
42-
* In addition to the permissions granted to you by the LGPL, you may combine
43-
* or link a "work that uses the Library" with a publicly distributed version
44-
* of this file to produce a combined library or application, then distribute
45-
* that combined work under the terms of your choosing, with no requirement
46-
* to comply with the obligations normally placed on you by section 4 of the
47-
* LGPL version 3 (or the corresponding section of a later version of the LGPL
48-
* should you choose to use a later version).
49-
*
50-
* This program is distributed in the hope that it will be useful,
51-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
52-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53-
* GNU Lesser General Public License for more details.
54-
*
55-
* You should have received a copy of the GNU Lesser General Public License
56-
* along with this program; if not, write to the Free Software
57-
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
58-
let version = "9.1.0"
59-
let header =
60-
"// Generated by ReScript, PLEASE EDIT WITH CARE"
61-
let package_name = ref "bs-platform"
62-
63-
end
641
module Ext_array : sig
652
#1 "ext_array.mli"
663
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -5942,6 +5879,69 @@ let proj_rel path = rev_lib_bs // path
59425879
(* let cmd_package_specs = ref None *)
59435880

59445881

5882+
end
5883+
module Bs_version : sig
5884+
#1 "bs_version.mli"
5885+
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5886+
*
5887+
* This program is free software: you can redistribute it and/or modify
5888+
* it under the terms of the GNU Lesser General Public License as published by
5889+
* the Free Software Foundation, either version 3 of the License, or
5890+
* (at your option) any later version.
5891+
*
5892+
* In addition to the permissions granted to you by the LGPL, you may combine
5893+
* or link a "work that uses the Library" with a publicly distributed version
5894+
* of this file to produce a combined library or application, then distribute
5895+
* that combined work under the terms of your choosing, with no requirement
5896+
* to comply with the obligations normally placed on you by section 4 of the
5897+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
5898+
* should you choose to use a later version).
5899+
*
5900+
* This program is distributed in the hope that it will be useful,
5901+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
5902+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5903+
* GNU Lesser General Public License for more details.
5904+
*
5905+
* You should have received a copy of the GNU Lesser General Public License
5906+
* along with this program; if not, write to the Free Software
5907+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5908+
5909+
val version : string
5910+
5911+
val header : string
5912+
5913+
val package_name : string ref
5914+
end = struct
5915+
#1 "bs_version.ml"
5916+
5917+
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
5918+
*
5919+
* This program is free software: you can redistribute it and/or modify
5920+
* it under the terms of the GNU Lesser General Public License as published by
5921+
* the Free Software Foundation, either version 3 of the License, or
5922+
* (at your option) any later version.
5923+
*
5924+
* In addition to the permissions granted to you by the LGPL, you may combine
5925+
* or link a "work that uses the Library" with a publicly distributed version
5926+
* of this file to produce a combined library or application, then distribute
5927+
* that combined work under the terms of your choosing, with no requirement
5928+
* to comply with the obligations normally placed on you by section 4 of the
5929+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
5930+
* should you choose to use a later version).
5931+
*
5932+
* This program is distributed in the hope that it will be useful,
5933+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
5934+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5935+
* GNU Lesser General Public License for more details.
5936+
*
5937+
* You should have received a copy of the GNU Lesser General Public License
5938+
* along with this program; if not, write to the Free Software
5939+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5940+
let version = "9.1.0"
5941+
let header =
5942+
"// Generated by ReScript, PLEASE EDIT WITH CARE"
5943+
let package_name = ref "bs-platform"
5944+
59455945
end
59465946
module Bsb_pkg_types : sig
59475947
#1 "bsb_pkg_types.mli"
@@ -16597,11 +16597,7 @@ let watch_mode = ref false
1659716597
let make_world = ref false
1659816598
let do_install = ref false
1659916599
let force_regenerate = ref false
16600-
let bs_version_string = Bs_version.version
16601-
let print_version_string () =
16602-
print_string bs_version_string;
16603-
print_newline ();
16604-
exit 0
16600+
1660516601
type spec = Bsb_arg.spec
1660616602

1660716603
let call_spec f : spec = Unit (Unit_call f )
@@ -16682,17 +16678,7 @@ let install_target () =
1668216678
if eid <> 0 then
1668316679
Bsb_unix.command_fatal_error install_command eid
1668416680

16685-
let global_help () =
16686-
print_string {|Available flags
16687-
-v, -version display version number
16688-
-h, -help display help
16689-
Subcommands:
16690-
build
16691-
clean
16692-
help
16693-
Run rescript subcommand -h for more details, for example
16694-
rescript build -h
16695-
|}
16681+
1669616682

1669716683
let build_subcommand ~start argv argv_len =
1669816684
let i = Ext_array.rfind_with_index argv Ext_string.equal separator in
@@ -16810,23 +16796,15 @@ let () =
1681016796
~per_proj_dir:Bsb_global_paths.cwd |> ignore;
1681116797
ninja_command_exit [||]
1681216798
end else
16813-
16814-
16815-
1681616799
match argv.(1) with
16817-
| "-version" | "-v"
16818-
-> print_version_string ()
16819-
| "-help" | "-h"
16820-
-> global_help ()
1682116800
| "build" ->
1682216801
build_subcommand ~start:2 argv argv_len
1682316802
| "clean" ->
1682416803
clean_subcommand ~start:2 argv
1682516804
| "init" ->
1682616805
init_subcommand ~start:2 argv
16827-
| "info" ->
16806+
| "info" -> (* internal *)
1682816807
info_subcommand ~start:2 argv
16829-
| "help" -> global_help ()
1683016808
| first_arg ->
1683116809
prerr_endline @@ "Unknown subcommand or flags: " ^ first_arg;
1683216810
exit 1

rescript

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
108108
*/
109109
var delegate_args = [];
110110
var process_argv = process.argv;
111-
var maybe_subcommand = process_argv[2];
112-
var isInBuildMode = maybe_subcommand === "build";
113111

114112
if (process.env.NINJA_ANSI_FORCED === undefined) {
115113
if (require("tty").isatty(1)) {
@@ -118,9 +116,33 @@ if (process.env.NINJA_ANSI_FORCED === undefined) {
118116
} else {
119117
dlog(`NINJA_ANSI_FORCED: "${process.env.NINJA_ANSI_FORCED}"`);
120118
}
119+
function help() {
120+
console.log(`Available flags
121+
-v, -version display version number
122+
-h, -help display help
123+
Subcommands:
124+
build
125+
clean
126+
format
127+
convert
128+
help
129+
Run rescript subcommand -h for more details,
130+
For example:
131+
rescript build -h
132+
rescript format -h
133+
`);
134+
}
135+
136+
var maybe_subcommand = process_argv[2];
121137

122-
var delegate_args = process_argv.slice(2);
123-
if (!isInBuildMode) {
138+
if (
139+
maybe_subcommand !== undefined &&
140+
maybe_subcommand !== "build" &&
141+
maybe_subcommand !== "clean" &&
142+
maybe_subcommand !== "init" &&
143+
maybe_subcommand !== "info"
144+
// delegate to native
145+
) {
124146
var bsc_exe = path.join(__dirname, process.platform, "bsc.exe");
125147
switch (maybe_subcommand) {
126148
case "format":
@@ -138,21 +160,22 @@ if (!isInBuildMode) {
138160
bsc_exe
139161
);
140162
break;
163+
case "-h":
164+
case "-help":
165+
case "help":
166+
help();
167+
break;
168+
case "-v":
169+
case "-version":
170+
console.log(require("./package.json").version);
171+
break;
141172
default:
142-
try {
143-
child_process.execFileSync(bsb_exe, delegate_args, {
144-
stdio: "inherit",
145-
});
146-
} catch (e) {
147-
if (e.code === "ENOENT") {
148-
// when rescript is not found
149-
console.log(String(e));
150-
process.exit(2);
151-
}
152-
}
153-
process.exit(0);
173+
console.error(`Unknown subcommand or flags: ${maybe_subcommand}`);
174+
help();
175+
process.exit(2);
154176
}
155177
} else {
178+
var delegate_args = process_argv.slice(2);
156179
var watch_mode = delegate_args.includes("-w");
157180
verbose = delegate_args.includes("-verbose");
158181

0 commit comments

Comments
 (0)