Skip to content

Commit

Permalink
Merge pull request #16 from jacebrowning/feature/custom-version-arg
Browse files Browse the repository at this point in the history
Add support for custom version arguments
  • Loading branch information
jacebrowning committed Oct 19, 2016
2 parents 8d67f7f + d27a93f commit 7cffc73
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 5 deletions.
32 changes: 31 additions & 1 deletion .verchew
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
[Python]
[Make]

cli = make

version = GNU Make


[Python 2]

cli = python2

version = Python 2.7.


[Python 3]

cli = python3

version = Python 3.5.


[pandoc]

cli = pandoc

version = 1.


[Graphviz]

cli = dot
cli_version_arg = -V

version = 2.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Revision History

## 0.4 (unreleased)

- Added support for custom version arguments.

## 0.3 (2016/10/18)

- Added support for detecting missing and broken programs.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ run: install

.PHONY: doctor
doctor: ## Confirm system dependencies are available
@ verchew/script.py
verchew/script.py

# PROJECT DEPENDENCIES #########################################################

Expand Down
15 changes: 15 additions & 0 deletions docs/cli/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ To call `verchew` from an arbitrary directory, pass it the path to the root of y
```sh
$ verchew --root=<path/to/project>
```

# Custom Version Arguments

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.

```
7 changes: 4 additions & 3 deletions verchew/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def check_dependencies(config):

for name, settings in config.items():
show("Checking for {0}...".format(name), head=True)
output = get_version(settings['cli'])
output = get_version(settings['cli'], settings.get('cli_version_arg'))
if settings['version'] in output:
show(_("~") + " MATCHED: {0}".format(settings['version']))
success.append(_("~"))
Expand All @@ -143,8 +143,9 @@ def check_dependencies(config):
return _("x") not in success


def get_version(program):
args = [program, '--version']
def get_version(program, argument=None):
argument = argument or '--version'
args = [program, argument]

show("$ {0}".format(" ".join(args)))
output = call(args)
Expand Down
3 changes: 3 additions & 0 deletions verchew/tests/test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def when_missing():
def when_found():
expect(get_version('python')).contains("Python ")

def with_custom_argument():
expect(get_version('python', argument='-V')).contains("Python ")


def describe_format():

Expand Down

0 comments on commit 7cffc73

Please sign in to comment.