summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Fix booleans without validate_type with argumentsLee Jarvis2023-02-261-0/+7
| | | | | | | | | | If we're not using `validate_type`, we shouldn't try to check a boolean flag's argument to check if it's valid (actually, we probably shouldn't even do that WITH using `validate_type`, but that's a separate issue). For now, this will prevent broken boolean flags. Fixes #279
* Augment tests for validated typesVictor Gama2023-02-152-6/+24
|
* Add optional type validationVictor Gama2023-02-151-0/+15
|
* Fix explicitly false booleansEugene Otto2022-09-301-1/+7
| | | | | | | | | | | | When a boolean option is explicitly set to `false`, e.g.: ```bash --option=false ``` it enters slop as the string value `'false'`. This commit updates the `BoolOption` option handler to interpret `'false'` and various other falsey values (`false`, `'false'`, `'no'`, `'off'`, `'0'`) as logically false.
* Handle strings containing =Connor Garvey2022-03-101-9/+18
|
* Add support for --opt="" for blank argumentsLee Jarvis2021-05-281-0/+10
| | | | | | | This is especially useful when your default option value is a non-blank value and you want users to be able to overwrite it with a blank value Closes #266
* Add simple tests for StringOptionJoe Gracyk2021-05-101-0/+14
|
* Add symbols to option typesJoe Gracyk2021-05-101-0/+14
|
* Fix bug with separators around `help: false` optsLee Jarvis2020-07-101-0/+11
| | | | | | | | | | | The separators rely on the indexes of the options before/after them, but we ignore `help: false` options when building the help string, so all of the positions are messed up. This change avoids ignoring those options during the iteration, and instead just doesn't append the option help to the string. Fixes #253
* Add basic test for Slop.parseLee Jarvis2020-01-281-0/+10
| | | | See https://github.com/leejarvis/slop/pull/251
* admit commentsHansuk2020-01-171-0/+4
| | | | | | | - https://github.com/leejarvis/slop/pull/250#discussion_r367361652 - https://github.com/leejarvis/slop/pull/250#discussion_r367420001 Signed-off-by: Hansuk <flavono123@gmail.com>
* support scientific nations for float optionsHansuk2020-01-161-1/+19
| | | | | | | - reference: https://stackoverflow.com/questions/638565/parsing-scientific-notation-sensibly - remove the todo comment(no idea for etc) Signed-off-by: Hansuk <flavono123@gmail.com>
* support + sign for float optionsHansuk2020-01-161-1/+5
| | | | Signed-off-by: Hansuk <flavono123@gmail.com>
* Tests on Ruby 2.7.0Juha Ylitalo2020-01-073-5/+5
|
* Test integer with plus sign as prefixJuha Ylitalo2019-08-301-1/+5
|
* Fix a bug that flag value is processed as flagSutou Kouhei2019-06-291-0/+6
| | | | | | | | If flag value starts with "-", unknown option error is raised. The current flag value check is "orig_arg == opt.value.to_s". There are some objects such as Regexp and Time that input value and its #to_s aren't same.
* Fix deprecation warning in testsLee Jarvis2019-01-211-1/+1
|
* Allow calling `Options#separator` without args, defaulting to an empty stringTeemu Matilainen2019-01-201-0/+6
| | | | | | | | It's clear that we want an empty line when calling `opts.separator` without arguments. Leave the examples in the Readme still for a while with the empty string to avoid confusion when using older versions.
* add Slop::Result#fetchGiovanni Benussi2018-06-271-0/+25
| | | | | | | | | | | | | | | | | | | | | | use Slop::Result#clean_key in Slop::Result#option fix typo in Slop::Result#[] and Slop::Result#fetch descriptions handle case when Slop::Result#fetch tries to fetch an option that is not provided and does not have a default value raise Slop::UnknownOption when Slop::Result#fetch tries to fetch an unexisting key set Slop::Result#clean_key method as private remove redundant Slop::Result#fetch tests update description of Slop::Result#fetch test when trying to access an unexisting option update error message when an option is not present on Slop::Result#fetch description of Slop::Result#fetch update expected error message on test for Slop::Result#fetch when an option is not present
* Handle equals character for non-option valuespedantic-equalsLee Jarvis2018-03-121-0/+5
| | | | | | | If the string includes an equals char but doesn't look like it's a possible candidate for a flag=value, we should ignore it see #226
* Add more tests for Options#separatorLee Jarvis2017-11-171-1/+22
| | | | | | And fixed the inevitable missed last separator.. Fixes #222
* Fix separator so it doesn't mutate user dataMarc-Andre Lafortune2017-11-131-1/+10
|
* Support for required optionsWilliam Woodruff2017-09-291-0/+14
| | | | | | | | | | | This commit introduces support for required options, which are options that cause the parser to raise a `MissingRequiredOption` exception if not present. Options can be marked as required by passing `required: true` in their configuration, and any errors caused by missing required options can be suppressed via `suppress_errors: true`.
* Fix bug preventing '--' being passed as the first argument.Thomas Bénéteau2017-08-051-0/+6
|
* Fix non-deterministic testLee Jarvis2017-05-011-1/+1
| | | | There's a FooOption defined in options_test.rb
* Add config option underscore_flagslbriais-feature/add_config_for_underscore_switchLaurent B2017-05-011-0/+4
| | | | | | | | | | | | | | The default behaviour of translation flags-with-dashes is to underscore them so they're symbol friendly. This config option allows us to avoid this translation and simply return the flags verbatim: opts = Slop.parse(underscore_flags: false) do |o| o.on "--foo-bar" end opts.to_hash #=> { :"foo-bar" => true } closes #204
* Fix ridiculous minitest warningLee Jarvis2017-04-292-3/+3
| | | | wat?
* Avoid deleting args after '--'Lee Jarvis2017-04-291-1/+2
| | | | | | | | Everything after -- is sacred and shouldn't be mutated. So lets just remove it all straight away and add it to our arguments list after we're done parsing Closes #194
* Fix support for parsing -x5Lee Jarvis2017-01-291-0/+13
| | | | | | | Thanks to @RickHull for the "smashing" terminology and various conversations Fixes #199
* Handle bad constant names in Slop.option_defined?Lee Jarvis2016-08-211-0/+17
| | | | Closes #198
* Support arguments to options with leading -Andrew Clemons2016-04-041-0/+21
| | | | | | | | This allows negative values as arguments to numeric options and strings starting with - for any other type. Fixes #170 Fixes #179
* Can specify a custom banner string in Options via configPhil Rees2016-03-181-1/+12
|
* Allow disabling the delimiter for array argumentsMike Pastore2016-02-181-0/+6
|
* Fix bug where true is passed to BoolOption block regardless of --no- prefixBen Brady2015-11-241-1/+7
|
* Fix bug regarding --foo=bar style optionsNaoki Mizuno2015-09-081-0/+5
| | | | | | | | | | This fixes the bug introduced in ebe678b1639654604b3e54b08ca710c38682b83e where the argument after a flag is naively deleted. For example, with --foo=bar baz , both `--foo=bar' and `baz' are deleted when only `--foo=bar' should be deleted.
* Fix arguments removed with option argumentsNaoki Mizuno2015-09-081-0/+5
| | | | See #181.
* #163 only raise MissingArgument if not default_valueBen Brady2015-06-301-0/+3
|
* Better handling of option names with multiple wordsTim Rogers2015-06-132-6/+18
|
* Support --no- prefix for inverting boolean optionsLee Jarvis2015-05-211-4/+9
| | | | closes #168
* Added support for RegexpLaurent Arnoud2015-05-171-0/+13
| | | | | Used to work on 3.6 See https://github.com/leejarvis/slop/commit/e2775e27d866ba85f6b6bf50536135ee4e93c93e
* Rewrite UnknownOption.getUnknownOption() to flagsigurdsvela2015-04-071-1/+1
| | | | | | Rewrite the UnknownOption.getUnknownOption() to use attr_reader :flags. And rename the initialize parameter unknownOption to flag.
* Rewrite MissingOption.getFlags() to flagssigurdsvela2015-04-071-1/+1
| | | | | | Removes the MissingOption.getFlags() function and replaces it with attr_reader :flags
* Implement getFlags in MissingArgumentsigurdsvela2015-04-061-0/+7
| | | | | | A function in MissingArgument that returns and array of all the flags that matches the option missing an argument
* Remove semi-colons to conform to the code stylesigurdsvela2015-04-061-1/+1
|
* Fix typo in commentsigurdsvela2015-04-061-1/+1
|
* Implement getUnknownMessage in UnknownOptionsigurdsvela2015-04-061-0/+7
| | | | | | | This allows to retrive the unknown option in question when catching the error. This can be useful to, for example, taylor a spesific output for common errors amongst users.
* Add explicit value setter to Result classLee Jarvis2015-02-041-0/+14
| | | | closes #162
* Remove "--" from the unprocessed argumentsDavid Rodríguez2015-01-111-0/+5
| | | | | The double dash is a valid (special) option for Slop, so like the rest of the options successfully processed, should be removed.
* Support `tail: true` config optionLee Jarvis2015-01-021-0/+6
|
* Reset parser every time parse is calledLee Jarvis2014-12-303-14/+14
|