diff --git a/CHANGELOG.md b/CHANGELOG.md index af65fd5..a2ee034 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Unreleased + +- Deprecated `versions` in favor of `version` option. +- Deprecated `|` in favor of `||` for checking multiple versions. + # 1.6.2 (2019-02-15) - Fixed handling of programs that produce output with file paths. diff --git a/README.md b/README.md index fc507ae..add9f31 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ version = 1.2 [Newer Working Program] cli = working-program -versions = 4.1 | 4.2 +version = 4.1 || 4.2 message = Version 4.x is required to get the special features. [Broken Program] @@ -77,7 +77,7 @@ Checking for Newer Working Program... $ working-program --version 1.2.3 -✘ EXPECTED: 4.1 | 4.2 +✘ EXPECTED: 4.1 || 4.2 ⭑ MESSAGE: Version 4.x is required to get the special features. Checking for Broken Program... diff --git a/docs/cli/configuration.md b/docs/cli/configuration.md index 7bccb67..865c61a 100644 --- a/docs/cli/configuration.md +++ b/docs/cli/configuration.md @@ -31,13 +31,13 @@ version = 16 # Multiple Versions -If your project can use multiple versions of a system dependency, use the `versions` setting and separate versions with the pipe character (`|`): +If your project can work with more than one version of a system dependency, separate them with a double pipe (`||`) symbol: ```ini [Python] cli = python -versions = Python 2 | Python 3 +version = Python 2 || Python 3 ``` # Optional Programs diff --git a/tests/test_cli.py b/tests/test_cli.py index 5bde98f..e3b9ca0 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -29,7 +29,7 @@ $ working-program --version 1.2.3 -✘ EXPECTED: 4.1 | 4.2 +✘ EXPECTED: 4.1 || 4.2 ⭑ MESSAGE: Version 4.x is required to get the special features. Checking for Broken Program... @@ -68,7 +68,7 @@ $ working-program --version sh: command not found: working-program -x EXPECTED: 4.1 | 4.2 +x EXPECTED: 4.1 || 4.2 * MESSAGE: Version 4.x is required to get the special features. Checking for Broken Program... diff --git a/verchew/script.py b/verchew/script.py index df487dc..e2df8cd 100755 --- a/verchew/script.py +++ b/verchew/script.py @@ -34,6 +34,7 @@ import os import re import sys +import warnings from collections import OrderedDict from subprocess import PIPE, STDOUT, Popen @@ -58,7 +59,7 @@ [Python] cli = python -versions = Python 3.5 | Python 3.6 +version = Python 3.5 || Python 3.6 [Legacy Python] @@ -198,9 +199,24 @@ def parse_config(path): data[section][name] = value for name in data: - versions = data[name].get('versions', data[name].pop('version', "")) - data[name]['versions'] = versions - data[name]['patterns'] = [v.strip() for v in versions.split('|')] + if 'versions' in data[name]: + warnings.warn( + "'versions' is deprecated, use 'version' instead", + DeprecationWarning + ) + version = data[name].pop('versions') or "" + else: + version = data[name].get('version') or "" + + if ' | ' in version: + warnings.warn( + "'|' is deprecated, use '||' to separate multiple versions", + DeprecationWarning + ) + version = version.replace(' | ', ' || ') + + data[name]['version'] = version + data[name]['patterns'] = [v.strip() for v in version.split('||')] return data @@ -219,15 +235,15 @@ def check_dependencies(config): break else: if settings.get('optional'): - show(_("?") + " EXPECTED: {0}".format(settings['versions'])) + show(_("?") + " EXPECTED: {0}".format(settings['version'])) success.append(_("?")) else: if QUIET: print("Unmatched {0} version: {1}".format( name, - settings['versions'], + settings['version'], )) - show(_("x") + " EXPECTED: {0}".format(settings['versions'])) + show(_("x") + " EXPECTED: {0}".format(settings['version'])) success.append(_("x")) if settings.get('message'): show(_("*") + " MESSAGE: {0}".format(settings['message'])) diff --git a/verchew/tests/test_script.py b/verchew/tests/test_script.py index e762385..db1e178 100644 --- a/verchew/tests/test_script.py +++ b/verchew/tests/test_script.py @@ -60,7 +60,7 @@ def with_an_empty_section(config): expect(parse_config(str(config))) == { 'Foobar': { - 'versions': '', + 'version': '', 'patterns': [''], }, } @@ -76,7 +76,7 @@ def with_a_filled_section(config): expect(parse_config(str(config))) == { 'Foobar': { 'cli': 'foobar', - 'versions': 'v1.2.3', + 'version': 'v1.2.3', 'patterns': ['v1.2.3'], }, } @@ -85,17 +85,48 @@ def with_multiple_versions(config): write(config, """ [Foobar] - version = 1 - versions = 2 | 3 | 4 + version = 2 || 3 || 4 """) expect(parse_config(str(config))) == { 'Foobar': { - 'versions': '2 | 3 | 4', + 'version': '2 || 3 || 4', 'patterns': ['2', '3', '4'], }, } + def with_legacy_versions_option(config): + write(config, """ + [Foobar] + + cli = foobar + versions = v1.2.3 + """) + + expect(parse_config(str(config))) == { + 'Foobar': { + 'cli': 'foobar', + 'version': 'v1.2.3', + 'patterns': ['v1.2.3'], + }, + } + + def with_legacy_versions_separator(config): + write(config, """ + [Foobar] + + cli = foobar + version = v1.2.3 | v1.2.4 + """) + + expect(parse_config(str(config))) == { + 'Foobar': { + 'cli': 'foobar', + 'version': 'v1.2.3 || v1.2.4', + 'patterns': ['v1.2.3', 'v1.2.4'], + }, + } + def describe_get_version():