Skip to content

Commit 6f7b872

Browse files
authored
Clean up new CLI's help pages (rescript-lang#5135)
1 parent ca74bf8 commit 6f7b872

File tree

6 files changed

+54
-47
lines changed

6 files changed

+54
-47
lines changed

jscomp/main/rescript_main.ml

+9-10
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,11 @@ let ninja_command_exit (type t) (ninja_args : string array) : t =
8585
What will happen, some flags are really not good
8686
ninja -C _build
8787
*)
88-
let clean_usage = "Usage : rescript.exe clean <options>\n\
89-
It only clean the current project by default"
90-
let build_usage = "Usage : rescript.exe build <options> -- <ninja_options>\n\
91-
It only builds the current project by default\n\
92-
For ninja options, try rescript.exe -- -h. \n\
93-
Note they are supposed to be internals and not reliable."
88+
let clean_usage = "Usage: rescript.exe clean <options>\n\n\
89+
`rescript clean` only cleans the current project\n"
90+
let build_usage = "Usage: rescript.exe build <options> -- <ninja_options>\n\n\
91+
`rescript build` implicitly builds dependencies if they aren't built\n\n\
92+
`rescript.exe -- -h` for Ninja options (internal usage only; unstable)\n"
9493

9594

9695

@@ -138,14 +137,14 @@ let build_subcommand ~start argv argv_len =
138137
"-w", unit_set_spec watch_mode,
139138
"Watch mode";
140139
"-with-deps", unit_set_spec make_world,
141-
"Build with deps";
140+
"Build dependencies explicitly";
142141
"-install", unit_set_spec do_install,
143142
"*internal* Install public interface files for dependencies ";
144143
(* This should be put in a subcommand
145144
previously it works with the implication `bsb && bsb -install`
146145
*)
147146
"-ws", string_set_spec (ref ""),
148-
"[host]:port set the host, port for websocket build notifications";
147+
"[host]:port set up host & port for WebSocket build notifications";
149148
"-regen", unit_set_spec force_regenerate,
150149
"*internal* \n\
151150
Always regenerate build.ninja no matter bsconfig.json is changed or not";
@@ -184,14 +183,14 @@ let clean_subcommand ~start argv =
184183
Bsb_arg.parse_exn
185184
~usage:clean_usage ~start ~argv [|
186185
"-with-deps", unit_set_spec make_world,
187-
"clean its deps too"
186+
"Clean dependencies too"
188187
|] failed_annon;
189188
if !make_world then
190189
Bsb_clean.clean_bs_deps Bsb_global_paths.cwd ;
191190
Bsb_clean.clean_self Bsb_global_paths.cwd
192191
let init_usage = "Init the project\n\
193192
rescript init [project-name]\n\
194-
defaults to the current directory if not set\n\
193+
defaults to the current directory if [project-name] isn't set\n\
195194
"
196195
let init_subcommand ~start argv =
197196
Bsb_arg.parse_exn

lib/4.06.1/rescript.ml

+9-10
Original file line numberDiff line numberDiff line change
@@ -16662,12 +16662,11 @@ let ninja_command_exit (type t) (ninja_args : string array) : t =
1666216662
What will happen, some flags are really not good
1666316663
ninja -C _build
1666416664
*)
16665-
let clean_usage = "Usage : rescript.exe clean <options>\n\
16666-
It only clean the current project by default"
16667-
let build_usage = "Usage : rescript.exe build <options> -- <ninja_options>\n\
16668-
It only builds the current project by default\n\
16669-
For ninja options, try rescript.exe -- -h. \n\
16670-
Note they are supposed to be internals and not reliable."
16665+
let clean_usage = "Usage: rescript.exe clean <options>\n\n\
16666+
`rescript clean` only cleans the current project\n"
16667+
let build_usage = "Usage: rescript.exe build <options> -- <ninja_options>\n\n\
16668+
`rescript build` implicitly builds dependencies if they aren't built\n\n\
16669+
`rescript.exe -- -h` for Ninja options (internal usage only; unstable)\n"
1667116670

1667216671

1667316672

@@ -16715,14 +16714,14 @@ let build_subcommand ~start argv argv_len =
1671516714
"-w", unit_set_spec watch_mode,
1671616715
"Watch mode";
1671716716
"-with-deps", unit_set_spec make_world,
16718-
"Build with deps";
16717+
"Build dependencies explicitly";
1671916718
"-install", unit_set_spec do_install,
1672016719
"*internal* Install public interface files for dependencies ";
1672116720
(* This should be put in a subcommand
1672216721
previously it works with the implication `bsb && bsb -install`
1672316722
*)
1672416723
"-ws", string_set_spec (ref ""),
16725-
"[host]:port set the host, port for websocket build notifications";
16724+
"[host]:port set up host & port for WebSocket build notifications";
1672616725
"-regen", unit_set_spec force_regenerate,
1672716726
"*internal* \n\
1672816727
Always regenerate build.ninja no matter bsconfig.json is changed or not";
@@ -16761,14 +16760,14 @@ let clean_subcommand ~start argv =
1676116760
Bsb_arg.parse_exn
1676216761
~usage:clean_usage ~start ~argv [|
1676316762
"-with-deps", unit_set_spec make_world,
16764-
"clean its deps too"
16763+
"Clean dependencies too"
1676516764
|] failed_annon;
1676616765
if !make_world then
1676716766
Bsb_clean.clean_bs_deps Bsb_global_paths.cwd ;
1676816767
Bsb_clean.clean_self Bsb_global_paths.cwd
1676916768
let init_usage = "Init the project\n\
1677016769
rescript init [project-name]\n\
16771-
defaults to the current directory if not set\n\
16770+
defaults to the current directory if [project-name] isn't set\n\
1677216771
"
1677316772
let init_subcommand ~start argv =
1677416773
Bsb_arg.parse_exn

rescript

+19-16
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function setUpWebSocket() {
125125
// @ts-ignore
126126
if (err !== undefined && err.code === "EADDRINUSE") {
127127
var error = std_is_tty ? `\x1b[1;31mERROR:\x1b[0m` : `ERROR:`;
128-
console.error(`${error} The websocket port number ${webSocketPort} is in use.
128+
console.error(`${error} The websocket port number ${webSocketPort} is in use.
129129
Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
130130
} else {
131131
console.error(err);
@@ -149,21 +149,24 @@ if (process.env.NINJA_ANSI_FORCED === undefined) {
149149
dlog(`NINJA_ANSI_FORCED: "${process.env.NINJA_ANSI_FORCED}"`);
150150
}
151151
function help() {
152-
console.log(`Available flags
153-
-v, -version display version number
154-
-h, -help display help
152+
console.log(`Usage: rescript <options> <subcommand>
153+
154+
\`rescript\` is equivalent to \`rescript build\`
155+
156+
Options:
157+
-v, -version display version number
158+
-h, -help display help
159+
155160
Subcommands:
156-
build
157-
clean
158-
format
159-
convert
160-
help
161-
Run rescript subcommand -h for more details,
162-
For example:
163-
rescript build -h
164-
rescript format -h
165-
The default \`rescript\` is equivalent to \`rescript build\` subcommand
166-
`);
161+
build
162+
clean
163+
format
164+
convert
165+
help
166+
167+
Run \`rescript <subcommand> -h\` for subcommand help. Examples:
168+
rescript build -h
169+
rescript format -h`);
167170
}
168171

169172
var maybe_subcommand = process_argv[2];
@@ -530,7 +533,7 @@ if (
530533
// helps avoid redundant build, but this will
531534
// save the event loop call `setImmediate`
532535
return;
533-
}
536+
}
534537
if (validEvent(event, reason)) {
535538
dlog(`\nEvent ${event} ${reason}`);
536539
LAST_FIRED_EVENT = event_time;

scripts/rescript_arg.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ function usage_b(b, usage, specs) {
3838
b.add(usage);
3939
b.add(`\nOptions:\n`);
4040
if(specs.length === 0){
41-
return
41+
return
4242
}
4343
var max_col = 0;
4444
for (let [key] of specs) {
4545
if (key.length > max_col) {
4646
max_col = key.length;
4747
}
4848
}
49-
for (let [key, _, doc] of specs) {
49+
for (let i = 0; i < specs.length; i++) {
50+
let [key, _, doc] = specs[i]
5051
if (!doc.startsWith("*internal*")) {
5152
b.add(" ")
5253
.add(key)
@@ -66,7 +67,9 @@ function usage_b(b, usage, specs) {
6667
cur = i + 1;
6768
}
6869
}
69-
b.add("\n");
70+
if (i < specs.length - 1) {
71+
b.add("\n");
72+
}
7073
}
7174
}
7275
}

scripts/rescript_convert.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
//@ts-check
22
var arg = require("./rescript_arg.js");
33
var format_usage = `Usage: rescript convert <options> [files]
4-
rescript convert -- it converts the current directory
5-
Note this subcommand will remove old reason/ml files and
6-
create new ReScript files, make sure your work is saved first.
4+
5+
\`rescript convert\` converts the current directory
6+
7+
**This command removes old Reason/OCaml files and creates new ReScript
8+
files. Make sure your work is saved first!**
79
`;
810

911
var child_process = require("child_process");
@@ -22,7 +24,7 @@ var specs = [
2224
[
2325
"-all",
2426
{ kind: "Unit", data: { kind: "Unit_set", data: formatProject } },
25-
"Formatting the whole project ",
27+
"Convert the whole project",
2628
],
2729
];
2830

scripts/rescript_format.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//@ts-check
22
var arg = require("./rescript_arg.js");
33
var format_usage = `Usage: rescript format <options> [files]
4-
rescript format -- it format the current directory
4+
5+
\`rescript format\` formats the current directory
56
`;
67
var child_process = require("child_process");
78
var path = require("path");
@@ -23,14 +24,14 @@ var specs = [
2324
[
2425
"-stdin",
2526
{ kind: "String", data: { kind: "String_set", data: stdin } },
26-
`[.res|.resi|.ml|.mli|.re|.rei] Read the format code from stdin and print the formatted code
27-
in the stdout (in rescript syntax)`,
27+
`[.res|.resi|.ml|.mli|.re|.rei] Read the code from stdin and print
28+
the formatted code to stdout in ReScript syntax`,
2829
],
2930
// ml|mli
3031
[
3132
"-all",
3233
{ kind: "Unit", data: { kind: "Unit_set", data: format } },
33-
"Formatting the whole project ",
34+
"Format the whole project ",
3435
],
3536
];
3637
var formattedStdExtensions = [".res", ".resi", ".ml", ".mli", ".re", ".rei"];

0 commit comments

Comments
 (0)