Yaron Minsky avatar Yaron Minsky committed b4825ea

more comments

Comments (0)

Files changed (2)

 open Core.Std
 
+(* A very basic command-line program, using Command, Core's Command line
+   parsing library.  *)
+
 let command =
+  (* [Commabd.basic] is used for creating a command.  Every command takes a text
+     summary and a command line spec *)
   Command.basic
     ~summary:"Hello World"
+    (* Command line specs are built up component by component, using a small
+       combinator library whose operators are contained in [Command.Spec] *)
     Command.Spec.(
       empty
       +> flag "-hello" (optional_with_default "Hello" string)
       +> flag "-world" (optional_with_default "World" string)
         ~doc:" The 'world' of 'hello world'"
     )
+    (* The command-line spec determines the argument to this function, which
+       show up in an order that matches the spec. *)
     (fun hello world () ->
       printf "%s %s!\n" hello world
     )
 
 let () =
-  Command.run command
+  (* Exn.handle_uncaught is here to improve how exceptions are printed out when
+     the program exits. *)
+  Exn.handle_uncaught ~exit:true (fun () -> Command.run command)
+(* The mli is here, and empty, so that the compiler will warn us about any
+   unused functions in the body.  *)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.