Skip to content

Commit 658c30c

Browse files
authored
Default to printing ns (human-readable) (rescript-lang#82)
Fixes rescript-lang#78
1 parent 900e485 commit 658c30c

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

syntax/src/napkin_cli.ml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ end = struct
2121
let interface = ref false
2222
let report = ref "pretty"
2323

24-
let usage = "Usage: napkinscript <options> <file>\nOptions are:"
24+
let usage = "Usage:\n napkinscript <options> <file>\n\n" ^
25+
"Examples:\n" ^
26+
" napkinscript myFile.res\n" ^
27+
" napkinscript -parse ml -print ns myFile.ml\n" ^
28+
" napkinscript -parse ns -print binary -interface myFile.resi\n\n" ^
29+
"Options are:"
2530

2631
let spec = [
2732
("-recover", Arg.Unit (fun () -> recover := true), "Emit partial ast");
28-
("-print", Arg.String (fun txt -> print := txt), "Print either binary or napkinscript");
29-
("-parse", Arg.String (fun txt -> origin := txt), "Parse reasonBinary or napkinscript");
30-
("-width", Arg.Int (fun w -> width := w), "Specify the line length that the printer will wrap on" );
33+
("-parse", Arg.String (fun txt -> origin := txt), "Parse reasonBinary, ml or ns. Default: ns");
34+
("-print", Arg.String (fun txt -> print := txt), "Print either binary or ns. Default: ns");
35+
("-width", Arg.Int (fun w -> width := w), "Specify the line length for the printer (formatter)");
3136
("-interface", Arg.Unit (fun () -> interface := true), "Parse as interface");
3237
(* ("-report", Arg.String (fun txt -> report := txt), "Stylize errors and messages using color and context. Accepts `Pretty` and `Plain`. Default `Plain`") *)
3338
]
@@ -52,11 +57,11 @@ module CliArgProcessor = struct
5257
in
5358
let printEngine =
5459
match target with
55-
| "ns" | "napkinscript" -> Napkin_driver.printEngine
5660
| "ml" | "ocaml" -> Napkin_ml_parser_driver.printEngine
5761
| "ast" -> Napkin_ast_debugger.printEngine
5862
| "sexp" -> Napkin_ast_debugger.sexpPrintEngine
59-
| _ -> Napkin_binary_driver.printEngine
63+
| "binary" -> Napkin_binary_driver.printEngine
64+
| _ -> Napkin_driver.printEngine
6065
in
6166

6267
let forPrinter = match target with
@@ -124,14 +129,14 @@ let () =
124129
""
125130
| files ->
126131
List.iter (fun filename ->
127-
CliArgProcessor.processFile
128-
~isInterface:!NapkinClflags.interface
129-
~width:!NapkinClflags.width
130-
~recover:!NapkinClflags.recover
131-
~target:!NapkinClflags.print
132-
~origin:!NapkinClflags.origin
133-
~report:!NapkinClflags.report
134-
filename
132+
CliArgProcessor.processFile
133+
~isInterface:!NapkinClflags.interface
134+
~width:!NapkinClflags.width
135+
~recover:!NapkinClflags.recover
136+
~target:!NapkinClflags.print
137+
~origin:!NapkinClflags.origin
138+
~report:!NapkinClflags.report
139+
filename
135140
) files
136141

137142
end

0 commit comments

Comments
 (0)