Skip to content

Commit f7c2f12

Browse files
committed
restructure args
1 parent 7cb5574 commit f7c2f12

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tools/bin/main.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ let main () =
5656
| "format-codeblocks" :: rest -> (
5757
match rest with
5858
| ["-h"] | ["--help"] -> logAndExit (Ok formatDocstringsHelp)
59-
| [path; "--stdout"] -> (
59+
| path :: args -> (
60+
let isStdout = List.mem "--stdout" args in
61+
let outputMode = if isStdout then `Stdout else `File in
6062
Clflags.color := Some Misc.Color.Never;
6163
match
62-
Tools.FormatCodeblocks.formatCodeBlocksInFile ~outputMode:`Stdout
63-
~entryPointFile:path
64+
( Tools.FormatCodeblocks.formatCodeBlocksInFile ~outputMode
65+
~entryPointFile:path,
66+
outputMode )
6467
with
65-
| Ok content -> print_endline content
66-
| Error e -> logAndExit (Error e))
67-
| [path] ->
68-
Tools.FormatCodeblocks.formatCodeBlocksInFile ~outputMode:`File
69-
~entryPointFile:path
70-
|> logAndExit
68+
| Ok content, `Stdout -> print_endline content
69+
| result, `File -> logAndExit result
70+
| Error e, _ -> logAndExit (Error e))
7171
| _ -> logAndExit (Error formatDocstringsHelp))
7272
| "reanalyze" :: _ ->
7373
let len = Array.length Sys.argv in

0 commit comments

Comments
 (0)