1. Yaron Minsky
  2. core hello world


Yaron Minsky  committed b4825ea

more comments

  • Participants
  • Parent commits ff8b174
  • Branches default

Comments (0)

Files changed (2)

File hello_world.ml

View file
 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 *)
     ~summary:"Hello World"
+    (* Command line specs are built up component by component, using a small
+       combinator library whose operators are contained in [Command.Spec] *)
       +> 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)

File hello_world.mli

View file
+(* The mli is here, and empty, so that the compiler will warn us about any
+   unused functions in the body.  *)