Commit Graph

62 Commits (master)

Author SHA1 Message Date
Gabriel Scherer 63eb3dad0d Arg: a new Rest_all spec, similar to Rest, that passes all arguments at once
In particular this allow to detect a Rest_all keyword followed by no
arguments at all (an empty list).
2020-06-05 22:06:21 +02:00
Valentin Gatien-Baron 36218f05ea Arg module sometimes misbehaved instead of rejecting invalid -keyword=arg inputs
When -a is defined as Unit, accepted -a=1.
When -a is defined as Tuple, accepted -a=1 b c as -a b=1 c=1.
When -a is defined as Rest, looped infinitely on -a=1.
2018-07-22 02:24:08 -04:00
David Allsopp b5d1929e87 Whitespace and overlong line fixes. 2018-06-14 15:15:34 +01:00
alainfrisch 35e15f6029 Avoid non-tail recursion when loading files in Arg.read_arg. 2017-10-04 16:49:42 +02:00
Nicolas Ojeda Bar 3db27cd3b6 Simplify, update Changes 2017-05-30 15:54:43 +02:00
Nicolas Ojeda Bar caf8ef1027 Only replace first tab by a space, leave rest of docstring as-is 2017-05-30 13:15:12 +02:00
Nicolas Ojeda Bar 0bb18d82d9 Arg.align: optionally use '\t' as alignment separator
Arg.align now optionally uses the tab character '\t' to separate the "unaligned"
and "aligned" parts of the documentation string. If tab is not present, then
space is used as a fallback. Allows to have spaces in the unaligned part, which
is useful for Tuple options.
2017-05-30 13:15:12 +02:00
Florian Angeletti 48546a720f Fix Stdlib.Arg: do no repeat usage_msg thrice (#999)
Fix Stdlib.Arg: do no repeat usage_msg thrice (GPR#999)
2017-01-15 20:37:41 +01:00
Bernhard Schommer 62335624a9
Added simple parse_expand and support ocamldep
The parse_expand function does the same as parse and parse_dynamic
but allows Expand. However it does not update current to avoid
the problem that the array is modified.

This function is used for the ocamlopt, ocamlc, ocamlcp,
ocamloptp and ocamldep.
2016-10-12 09:30:54 +02:00
Bernhard Schommer bfd7e12dff
Trim CR, remove inw parameter and updated docu.
The read_aux function trims the cr character for the new-line
based method and the write functions are simplified without an
additional sep function.

The argument names are changed to match the default naming format
and the documentation is updated to match the implementation
behavior.

Also two new tests for reading and writing empty command lines as
well as a command lines containing empty arguments are added.
2016-10-11 18:50:01 +02:00
Bernhard Schommer 967b273632
Added functions to read/write cmdline arguments
The function read_arg, read_arg0, write_arg and write_arg0 read
and write command line arguments to a file which are either
separated by a NUL character or by new lines.
2016-10-10 12:10:05 +02:00
Bernhard Schommer 64ef11a634 add Arg.Expand (#778)
Add the `Arg.Expand` constructor to `Arg.spec`. This new specification allows the user to expand the `argv` array being parsed, for instance to implement responsefile support.

A new function `Arg.parse_and_expand_argv_dynamic` is added. It takes both `current` and `argv` as references and as mandatory arguments. This function allows the user to access the `argv` array after expansion.

To avoid confusion regarding the `?current` argument of the various parsing functions as well as with `Arg.current`, `Arg.Expand` is only allowed with the new function.

Tests for this PR are added to the testsuite.
2016-10-07 18:28:30 +01:00
Damien Doligez 520fb2df50 Merge tag 4.03.0 into trunk. 2016-04-28 16:13:21 +02:00
Alain Frisch 8557a86477 Also enable more warnings in stdlib/ and fix them. 2016-03-15 22:47:26 +01:00
Damien Doligez 5401ce8473 Update headers for the new license.
Remains to be done: remove all headers in testsuite/tests.
2016-02-18 16:59:16 +01:00
Richard W.M. Jones da02953570 arg: Allow flags such as --flag=arg as well as --flag arg.
Allow flags to be followed directly by their argument, separated by an '='
sign.  This is consistent with what GNU getopt_long and many other
command line parsing libraries allow.

Fix for the following issue:
http://caml.inria.fr/mantis/view.php?id=5197
2015-11-25 22:18:47 +01:00
Richard W.M. Jones d431b5bbd6 arg: Add no_arg and get_arg helper functions.
The no_arg function in this patch is a no-op.  It will do something
useful in the followups.

The get_arg function simple checks the next position on the command
line exists and returns that argument or raises a Arg.Missing.

This patch should introduce no functional change, it is simply code
refactoring.

In particular, this should not change the treatment of Arg.current
(see: http://caml.inria.fr/mantis/view.php?id=5197#c11147)
2015-11-25 22:14:36 +01:00
Alain Frisch a21eaeaa40 GPR#254: @ocaml.arg_on_literal_pattern attribute on constructors
to warn when the argument is matches against a constant pattern.
This attributes is applied on predefined exception constructors
which take an purely informational (with no stability guarantee)
message.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16502 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-15 12:30:10 +00:00
Damien Doligez 031cffd155 merge branch 4.02 from release 4.02.0 to release 4.02.1
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15558 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-10-15 13:34:58 +00:00
Damien Doligez 34752cdc5a minor clean-ups
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14642 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-04-18 15:29:56 +00:00
Damien Doligez 493704f300 PR#5827: provide a dynamic command line parsing mechanism
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13772 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-06-13 11:26:16 +00:00
Damien Doligez c63f9e0957 fix a few problems with whitespace and over-long lines
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13393 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-03-09 22:38:52 +00:00
Damien Doligez def31744f9 remove all $Id keywords
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13013 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-10-15 17:50:56 +00:00
Alain Frisch e489d6e3f4 Eliminate useless rec.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12507 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-05-29 12:52:44 +00:00
Jonathan Protzenko 632cea70f8 Followup fix to #5437: make sure [align] doesn't add padding to undocumented options, so that these don't show up when passed to [parse] or [usage].
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11946 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-12-23 13:34:13 +00:00
Jonathan Protzenko b47d5b20f2 Fix #5437: when registering an option with Arg, if the option has an empty doc string, do not include it when printing the usage.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11939 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-12-22 14:04:18 +00:00
Damien Doligez 3b507dd1aa renaming of Objective Caml to OCaml and cleanup of copyright headers
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11156 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-07-27 14:17:02 +00:00
Damien Doligez c91db736b1 merge changes from 3.12.0 to 3.12.1
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11123 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-07-20 09:17:07 +00:00
Damien Doligez 9ea5edac9a merge changes 3.10.0 -> 3.10.1
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8768 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2008-01-11 16:13:18 +00:00
Xavier Leroy 63c1789b5e Fusion des modifs faites sur la branche release jusqu'a la release 3.08.0
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6553 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-07-13 12:25:21 +00:00
Damien Doligez 97ed033e88 PR#2297, suite
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6384 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-06-11 23:45:46 +00:00
Damien Doligez 48d626ac16 PR#1931
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5934 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-11-19 14:01:23 +00:00
Pierre Weis fa91038ef2 Suite à la remarque de Didier.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5888 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-10-27 10:37:31 +00:00
Damien Doligez ed53ef381a bug findlib/Stolpmann
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5735 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-07-24 18:23:54 +00:00
Damien Doligez 12690ec2d8 bug de currification
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5648 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-07-03 13:17:09 +00:00
Damien Doligez 901936498a changement de parse_argv en cas d'erreur
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5604 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-06-19 18:13:31 +00:00
Damien Doligez 0b2e6f5f7c PR#1709
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5591 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-06-12 11:13:40 +00:00
Damien Doligez 313d77d1cb PR#1532
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5578 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-05-23 14:34:23 +00:00
Pierre Weis 1d52692ccf Adding new arguments types: boolean with spec Bool for function taking
a boolean as argument, and tuples with spec Tuple of spec list for
functions that takes more than one argument in turn on the command
line. For instance Arg.(Tuple [Arg.Int f; Arg.Bool b; Arg.Int g])
specifies an option that will take 3 elements on the command line and
will call f, b, and g in turn with converted values of the
corresponding types.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5505 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-04-25 10:19:35 +00:00
Damien Doligez 8a20bd757d completude de la doc, typo sur anon_fun
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5434 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-03-12 16:36:28 +00:00
Pierre Weis 6cdad3430c adding some semantics on the string type for specs
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5316 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-12-08 15:17:30 +00:00
Damien Doligez faff950d11 petit glitch
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5229 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-11-02 21:47:02 +00:00
Damien Doligez d4bd2173aa PR#1200
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5228 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-11-02 21:24:30 +00:00
Pierre Weis ae91006786 Documentation + parse_argv introduction.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4557 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-03-23 16:30:01 +00:00
Pierre Weis e40ea8f198 Generalization of Arg.parse into Arg.parse_array: we now can parse an
arbitrary string array built during program execution.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4556 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-03-22 20:46:06 +00:00
Pierre Weis f187b04ee0 Parsing of float arguments was not properly handled in case of invalid
argument.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4550 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2002-03-21 10:45:20 +00:00
Xavier Leroy 7501784c80 MAJ en-tetes pour mentionner la 'special exception' sur la LGPL
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4144 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2001-12-07 13:41:02 +00:00
Damien Doligez dcbb92b2d0 typo
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3646 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2001-08-21 18:49:22 +00:00
Damien Doligez f5759d294a arg: ajout --help; random: meilleur init
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3644 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2001-08-21 15:10:51 +00:00
Damien Doligez dcc3b0ce03 gc.ml, gc.mli: compteurs flottants
arg.ml: affichage option -help


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3399 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2001-02-05 14:59:24 +00:00