From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 5CA24801CD for ; Fri, 18 Aug 2017 05:05:52 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=berenger@bioreg.kyushu-u.ac.jp; spf=None smtp.mailfrom=berenger@bioreg.kyushu-u.ac.jp; spf=None smtp.helo=postmaster@h4.hosting4.cc.kyushu-u.ac.jp Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of berenger@bioreg.kyushu-u.ac.jp) identity=pra; client-ip=133.5.13.5; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="berenger@bioreg.kyushu-u.ac.jp"; x-sender="berenger@bioreg.kyushu-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of berenger@bioreg.kyushu-u.ac.jp) identity=mailfrom; client-ip=133.5.13.5; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="berenger@bioreg.kyushu-u.ac.jp"; x-sender="berenger@bioreg.kyushu-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@h4.hosting4.cc.kyushu-u.ac.jp) identity=helo; client-ip=133.5.13.5; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="berenger@bioreg.kyushu-u.ac.jp"; x-sender="postmaster@h4.hosting4.cc.kyushu-u.ac.jp"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AfDLL1x9xgFDd/f9uRHKM819IXTAuvvDOBiVQ1KB+?= =?us-ascii?q?2+wcTK2v8tzYMVDF4r011RmSAtWdtqoMotGVmp6jcFRI2YyGvnEGfc4EfD4+ou?= =?us-ascii?q?JSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47ITgaN+TjqsXZSR02+ZkJJ?= =?us-ascii?q?IbH+E4vWysC2zPya+pvJYgwOiiDuT6l1KUCYtwzXvc4XmsNIB5wc7DTkmDMcce?= =?us-ascii?q?lMyGVnKEi7lRf7/Mq/up1y7j9Qprc8scdLF6fiKfdrBYdEBSgrZjhmrPbgsgPO?= =?us-ascii?q?GFbX6w=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CBAgARWZZZlwUNBYVdGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBFQEBAQECAQEBAQgBAQEBhBMDkBenNoIEASeKPBQBAQEBAQEBAQEBARI?= =?us-ascii?q?BAQEBAQYYBleCMwUDBAwSgmUEgQcCJgIhSwgBAReKFBGqBoFsOodxGoQIBYELg?= =?us-ascii?q?h2FXIFwhUmBAoJHgmEFh2QHiSqBDo4mHoc2jG6LSIcSApYdNoErgQyFEAwBU4I?= =?us-ascii?q?CiDUMggEBAQE?= X-IPAS-Result: =?us-ascii?q?A0CBAgARWZZZlwUNBYVdGgEBAQECAQEBAQgBAQEBFQEBAQE?= =?us-ascii?q?CAQEBAQgBAQEBhBMDkBenNoIEASeKPBQBAQEBAQEBAQEBARIBAQEBAQYYBleCM?= =?us-ascii?q?wUDBAwSgmUEgQcCJgIhSwgBAReKFBGqBoFsOodxGoQIBYELgh2FXIFwhUmBAoJ?= =?us-ascii?q?HgmEFh2QHiSqBDo4mHoc2jG6LSIcSApYdNoErgQyFEAwBU4ICiDUMggEBAQE?= X-IronPort-AV: E=Sophos;i="5.41,391,1498514400"; d="scan'208";a="234707595" Received: from hosting4.cc.kyushu-u.ac.jp (HELO h4.hosting4.cc.kyushu-u.ac.jp) ([133.5.13.5]) by mail3-smtp-sop.national.inria.fr with ESMTP; 18 Aug 2017 05:05:18 +0200 Received: from [192.168.2.36] (unknown [133.5.218.148]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: berenger@bioreg.kyushu-u.ac.jp) by h4.hosting4.cc.kyushu-u.ac.jp (hde-lc-postfix) with ESMTPSA id A37722ACB1B; Fri, 18 Aug 2017 12:05:17 +0900 (JST) (envelope-from berenger@bioreg.kyushu-u.ac.jp) To: caml-list@inria.fr From: Francois BERENGER Message-ID: <0d430eea-d929-3d7a-a1b0-138daabd1a12@bioreg.kyushu-u.ac.jp> Date: Fri, 18 Aug 2017 12:05:17 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: [Caml-list] [ANN] release of minicli-1.0.0 Dear OCaml users, I am pleased to announce the first release of minicli. minicli is a minimalist library for command line parsing. The code is here: https://github.com/UnixJunkie/minicli It should be available in opam soon. A small example being better than a long discourse, here is an example client program: --- open Printf let main () = let argc, args = CLI.init () in if argc = 1 then (printf "usage:\n\ %s {-i|--input} {-o|--output} -n -x \ [-v] [--hi ]\n" Sys.argv.(0); exit 1); let input_fn = CLI.get_string ["-i";"--input"] args in let output_fn = CLI.get_string ["-o"] args in let n = CLI.get_int ["-n"] args in let x = CLI.get_float ["-x"] args in let verbose = CLI.get_set_bool ["-v"] args in let maybe_say_hi = CLI.get_string_opt ["--hi"] args in printf "i: %s o: %s n: %d x: %f v: %s\n" input_fn output_fn n x (string_of_bool verbose); match maybe_say_hi with | None -> () | Some name -> printf "Hi %s!\n" name let () = main () --- Here is an example session of a user playing with this program: --- # ./test usage: ./test {-i|--input} {-o|--output} -n -x [-v] [--hi ] # ./test -i Fatal error: exception CLI.No_param_for_option("-i") # ./test -i input.txt Fatal error: exception CLI.Option_is_mandatory("-o") # ./test -i input.txt -o output.txt Fatal error: exception CLI.Option_is_mandatory("-n") # ./test -i input.txt -o output.txt -n /dev/null Fatal error: exception CLI.Not_an_int("/dev/null") # ./test -i input.txt -o output.txt -n 123 Fatal error: exception CLI.Option_is_mandatory("-x") # ./test -i input.txt -o output.txt -n 123 -x /dev/null Fatal error: exception CLI.Not_a_float("/dev/null") # ./test -i input.txt -o output.txt -n 123 -x 0.123 i: input.txt o: output.txt n: 123 x: 0.123000 v: false # ./test -i input.txt -o output.txt -n 123 -x 0.123 -v i: input.txt o: output.txt n: 123 x: 0.123000 v: true # ./test -i input.txt -o output.txt -n 123 -x 0.123 -v -i input.bin Fatal error: exception CLI.More_than_once("-i, --input") --- minicli doesn't generate any kind of documentation automatically. It is up to the programmer to generate a useful and up to date usage message or to handle {-h|--help}. More complete solutions to command line parsing are the Arg module from the stdlib or the cmdliner library. Best regards, Francois.