Commit Graph
62 Commits
Author SHA1 Message Date
Eksperimental 27c16dc063 Standardize use of key-value pair (#10676) 2021-01-26 15:25:47 +01:00
José Valim 571e05a38f Throughout reject aliases starting with numbers 2020-11-20 09:18:58 +01:00
José Valim 876e260e69 Properly expand option aliases followed by numbers 2020-11-20 09:00:51 +01:00
José Valim e1f347b75a Add async: true to tests using capture_io :stderr 2019-11-15 10:00:16 +01:00
José Valim c5e0704916 Move some runtime deprecations to compile time
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2018-07-19 22:42:14 +02:00
José Valim 5405a165d8 Do not raise if switches option finds an undefined switch
Otherwise the code may fail or not depending on the modules
loaded. The current code simply ignores whatever it is not
listed.

This commit also refactored the docs and tests.
2018-02-20 12:22:12 +01:00
Unai Esteibar 33306d7313 Deprecate dynamic mode in OptionParser and promote strict (#7366)
Fixes #7278
2018-02-20 10:32:51 +01:00
José Valim c217203558 Improvements to previously formatted files 2017-10-11 22:59:30 +02:00
Tobiasz Małecki f81e2af358 Run code formatter on lib/elixir/test/elixir/option_parser_test.exs (#6913) 2017-10-11 22:31:40 +02:00
Aleksei Magusev 55d4dd1502 Fix "floating-point" spelling 2017-05-21 13:01:56 +02:00
Eksperimental 2ef963acd0 Add test for OptionParser.parse/2 when it raises (#5838) 2017-03-05 11:08:16 +01:00
Andrew Dryga b116f0dd19 Fix code style in tests for OptionParser (#5714) 2017-01-29 00:51:50 +01:00
Andrew Dryga 403368d2be Implement allow_inexistent_atoms for OptionParser (#5709) 2017-01-28 22:40:09 +01:00
Aleksei Magusev fd217d49ae Minor grammar fixes 2016-12-11 13:12:09 +01:00
Aleksei Magusev 9b5810c8ec Minor improvements around OptionParser.to_argv/2 2016-11-09 20:43:02 +01:00
Muaaz Saleem 40ff544ba7 Fixing :count support in OptionParser.to_argv (#5394) 2016-11-02 11:46:29 +01:00
Aleksei Magusev c1c53da900 Rename args -> argv in OptionParserTest 2016-08-13 14:08:37 +02:00
Aleksei Magusev 8c68ab6f2e Use String.to_existing_atom/1 for option conversion (#5134) 2016-08-13 14:06:48 +02:00
Andrea Leopardi 80aec928fc Expand multi-letter aliases in OptionParser (#5025)
Before this commit, -abc was processed by OptionParser as an alias.
With this commit, we deprecate this behaviour: if -abc still matches
an alias, we warn, otherwise, we split it into -a -b -c.
2016-07-20 10:39:52 +02:00
José Valim 91aa29d1b4 InvalidOptionError becomes ParseError 2016-05-21 21:18:50 +02:00
Milton Mazzarri 3f814349fd Add parse!/2 and parse_head!/2 to OptionParser
Improve OptionParser to have a bang alternative for `parse/2` and
`parse_head/2`, this new functions will raise an
`OptionParser.InvalidOptionError` exception if any invalid option were
encountered.

Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2016-05-21 19:49:07 +02:00
Mr C0B 7efc40016a improve option_parser.ex to support counter 🐝 (#4412) 2016-05-21 19:05:25 +02:00
Brandon Shroyer bfad62c25e Allow OptionParser to parse negative numbers
* Correctly parse negative numbers as arguments in OptionParser

* Correctly parse negative integers as option values in OptionParser

* Add additional OptionParser tests for negative floating point numbers

* Add negative number tests for double-dash options in OptionParser
2016-04-03 09:24:53 +02:00
Aleksei Magusev 9ac3c2e00d Make import with conflicting options to raise 2015-12-07 21:01:28 +01:00
Joe Yates 9b9b324241 Raise error for incompatible OptionParser options
* supplying :switch together with :strict raises an error.
* closes #4035.
2015-12-03 00:32:45 +01:00
Aleksei Magusev f8a82f604a Move doctests from central place to the modules they describe 2015-11-25 00:26:07 +01:00
José Valim ce3674dd07 Add OptionParser.to_argv/1 2014-07-16 22:22:02 +02:00
José Valim 6ed7e40d03 Add OptionParser.split/1 2014-07-10 17:58:19 +02:00
José Valim 6378750b12 Only accept --no-SWITCH for booleans
The previous behaviour was confusing and a special case.
This enables negated switches only for booleans, otherwise
it is considered as a regular switch (as the combination
of --no-SWITCH for any other type is an error anyway).
2014-07-10 14:05:49 +02:00
Alexei Sholik e942c07f34 Do not allow underscores in option names. Closes #2391 2014-06-12 19:26:47 +03:00
Alexei Sholik 4cc28c2e8c Return invalid options as strings 2014-05-22 00:05:41 +03:00
José Valim 927594bb14 Always return nil for undefined options (#2308) 2014-05-21 21:09:01 +02:00
Alexei Sholik a9375903ae Do not assume invalid options are of boolean type 2014-05-21 17:36:19 +03:00
Alexei Sholik fb2686fe37 Parse "-" as a plain argument 2014-05-21 13:55:28 +03:00
José Valim cb0c3d8a2a Support :strict option on parse and improve return types 2014-05-21 11:50:11 +02:00
Alexei Sholik 142ebc3ecd Fix handling of boolean options with bad values 2014-05-20 17:32:12 +03:00
Alexei Sholik 339c57f1c6 Fix value normalization in strict mode 2014-05-20 17:32:12 +03:00
Aleksei Magusev c0bc64fb19 Change OptionParser to remove the end of command options (--) 2014-05-20 12:49:10 +04:00
Alexei Sholik 24c17c350c Format OptionParser tests more nicely 2014-05-12 21:27:44 +03:00
Alexei Sholik 2187db5415 Don’t ignore values for ‘--no-*’ options 2014-05-12 21:24:31 +03:00
Alexei Sholik 84cdbe3562 Add more sanity-check tests for OptionParser 2014-05-12 21:24:31 +03:00
Alexei Sholik 95ed007b1c Properly handle non-boolean values for boolean options 2014-05-12 21:24:31 +03:00
Aleksei Magusev 698d1f6440 Fix handling of end of command options (--) in OptionParser 2014-05-10 20:10:23 +04:00
José Valim d53a6a3491 Ensure string switches are not treated as booleans, closes #2218 2014-04-30 12:48:39 +02:00
José Valim 56f15d9f4e Do not add spaces after { and before }
This makes the source code consistent with the result
returned by inspect/2.
2014-04-21 19:06:35 +02:00
José Valim fd8859abdd Do not recognize undefined aliases as switches 2014-02-17 15:52:44 +01:00
José Valim aaebf84440 Always stop on --, even for parse 2013-08-16 09:28:58 +02:00
Thomaz Leite abbbcdf659 Update OptionParser test for permanent invalid list 2013-08-09 09:52:15 -07:00
Thomaz Leite 06bc04a7bf Improve OptionParser switch validation
This adds a third element to the tuple returned from OptionParser.parse/2 when the value for an option doesn't match its switch type.
2013-08-09 09:52:15 -07:00
José Valim 456b84616c mix run now properly sets System.argv 2013-07-27 10:17:02 +02:00