domtool-config: print errors on stderr, return failure code, export vmaildb
[hcoop/domtool2.git] / src / main-config.sml
index e8be17a..a3fc686 100644 (file)
@@ -27,6 +27,8 @@
 *)
 
 fun println x = (print x; print "\n")
+fun printerr x = (TextIO.output (TextIO.stdErr, x); TextIO.flushOut TextIO.stdErr)
+fun die reason = (printerr reason; printerr "\n"; OS.Process.exit OS.Process.failure)
 
 val _ =
     (case CommandLine.arguments () of 
@@ -38,9 +40,11 @@ val _ =
                                                         "ca" => println Config.caDir
                                                       | "certs" => println Config.certDir
                                                       | "keys" => println Config.keyDir
-                                                      | _ => println "Invalid cert path type")
-                               | _ => print "Invalid path type\n")
+                                                      | "truststore" => println Config.trustStore
+                                                      | _ => die "Invalid cert path type")
+                               | ["vmaildb"] => println Config.Vmail.userDatabase
+                               | _ => die "Invalid path type")
       | ["-nodes"] => (app (fn (n, _) => (print n; print " ")) Config.nodeIps;
                       print "\n")
       | ["-domain"] => println Config.defaultDomain
-      | _ => print "Invalid command-line arguments\n")
+      | _ => die "Invalid command-line arguments")