Skip to content

Commit

Permalink
Add setting to mark programs as optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Sep 10, 2017
1 parent a9b248d commit 407df6f
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Revision History

## 1.2 (unreleased)

- Added `optional = true` settings to downgrade errors to warnings.

## 1.1 (2017/05/17)

- Added `--init` command to generate a sample configuration file.
Expand Down
14 changes: 13 additions & 1 deletion README.md
Expand Up @@ -50,6 +50,12 @@ version = 4.
cli = broken-program
version = 1.2.3

[Optional Missing Program]

cli = missing-program
version = 1.2.3
optional = true

[Missing Program]

cli = missing-program
Expand Down Expand Up @@ -79,11 +85,17 @@ $ broken-program --version
An error occurred.
✘ EXPECTED: 1.2.3

Checking for Optional Missing Program...

$ missing-program --version
sh: command not found: missing-program
⚠ EXPECTED: 1.2.3

Checking for Missing Program...

$ missing-program --version
sh: command not found: missing-program
✘ EXPECTED: 1.2.3

Results: ✔ ✘ ✘ ✘
Results: ✔ ✘ ✘
```
13 changes: 11 additions & 2 deletions docs/cli/options.md
Expand Up @@ -28,14 +28,23 @@ $ verchew --init
If one of your system dependencies using an argument other than `--version` to display its version information, this can be changed in the configuration file using the `cli_version_arg` setting:

```ini

[Graphviz]

cli = dot
cli_version_arg = -V

version = 2.
```

# Optional Programs

If one of your system dependencies is optional or you only want to show a warning for incompatible versions, include the `optional` setting:

```ini
[Terminal Notifier]

cli = terminal-notifier
version = 1.8
optional = true
```

# Exit Codes
Expand Down
6 changes: 6 additions & 0 deletions examples/verchew.ini
Expand Up @@ -13,6 +13,12 @@ version = 4.
cli = broken-program
version = 1.2.3

[Optional Missing Program]

cli = missing-program
version = 1.2.3
optional = true

[Missing Program]

cli = missing-program
Expand Down
1 change: 1 addition & 0 deletions scent.py
Expand Up @@ -39,6 +39,7 @@ def python(*_):
(('make', 'test-all'), "Combined Tests", False),
(('make', 'check'), "Static Analysis", True),
(('make', 'doc'), None, True),
(('make', 'doctor', '-C', 'examples'), "Examples", True),
), start=1):

if not run(command, title, count, retry):
Expand Down
19 changes: 16 additions & 3 deletions tests/test_cli.py
Expand Up @@ -36,17 +36,24 @@
An error occurred.
✘ EXPECTED: 1.2.3
Checking for Optional Missing Program...
$ missing-program --version
sh: command not found: missing-program
⚠ EXPECTED: 1.2.3
Checking for Missing Program...
$ missing-program --version
sh: command not found: missing-program
✘ EXPECTED: 1.2.3
Results: ✔ ✘ ✘ ✘
Results: ✔ ✘ ✘
"""

UNSTYLED_OUTPUT = STYLED_OUTPUT.replace('✔', '~').replace('✘', 'x')
UNSTYLED_OUTPUT = STYLED_OUTPUT \
.replace('✔', '~').replace('⚠', '?').replace('✘', 'x')

UNSTYLED_OUTPUT_WINDOWS = """
Checking for Working Program...
Expand All @@ -67,13 +74,19 @@
sh: command not found: broken-program
x EXPECTED: 1.2.3
Checking for Optional Missing Program...
$ missing-program --version
sh: command not found: missing-program
? EXPECTED: 1.2.3
Checking for Missing Program...
$ missing-program --version
sh: command not found: missing-program
x EXPECTED: 1.2.3
Results: x x x x
Results: x x x ? x
"""

Expand Down
9 changes: 7 additions & 2 deletions verchew/script.py
Expand Up @@ -40,7 +40,7 @@
from subprocess import Popen, PIPE, STDOUT
import logging

__version__ = '1.1'
__version__ = '1.2b1'

PY2 = sys.version_info[0] == 2
CONFIG_FILENAMES = ['.verchew.ini', 'verchew.ini', '.verchew', '.verchewrc']
Expand Down Expand Up @@ -74,12 +74,14 @@
""".strip()
STYLE = {
"~": "✔",
"?": "⚠",
"x": "✘",
"~": "✔"
}
COLOR = {
"x": "\033[91m", # red
"~": "\033[92m", # green
"?": "\033[93m", # yellow
None: "\033[0m", # reset
}

Expand Down Expand Up @@ -188,6 +190,9 @@ def check_dependencies(config):
if match_version(settings['version'], output):
show(_("~") + " MATCHED: {0}".format(settings['version']))
success.append(_("~"))
elif settings.get('optional'):
show(_("?") + " EXPECTED: {0}".format(settings['version']))
success.append(_("?"))
else:
show(_("x") + " EXPECTED: {0}".format(settings['version']))
success.append(_("x"))
Expand Down

0 comments on commit 407df6f

Please sign in to comment.