Skip to content

Commit 296a402

Browse files
committed
add support for defining cmd on a per-project level
* implements a custom `cmd()` method to check for the existence of an inline `cmd` setting * updated README documentation to show example of new functionality * add message file for the next version of the package closes #10
1 parent eae35fc commit 296a402

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ To install via Package Control, do the following:
2323
## Settings
2424
For general information on how SublimeLinter works with settings, please see [Settings](http://sublimelinter.readthedocs.org/en/latest/settings.html). For information on generic linter settings, please see [Linter Settings](http://sublimelinter.readthedocs.org/en/latest/linter_settings.html).
2525

26+
### Project Specific Executable
27+
It is possible to specify the `phpcs` executable that should be used to lint your code on a per-project level.
28+
29+
**Example:**
30+
```json
31+
{
32+
"SublimeLinter": {
33+
"linters": {
34+
"phpcs": {
35+
"cmd": "${project}/vendor/bin/phpcs"
36+
}
37+
}
38+
}
39+
}
40+
```
41+
2642
## Contributing
2743
If you would like to contribute enhancements or fixes, please do the following:
2844

linter.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,21 @@ class Phpcs(Linter):
2424
r'message="(?P<message>.*)" source'
2525
)
2626
executable = 'phpcs'
27-
cmd = 'phpcs --report=checkstyle'
2827
defaults = {
2928
'--standard=': 'PSR2',
3029
}
3130
inline_overrides = ('standard')
3231
tempfile_suffix = 'php'
32+
33+
def cmd(self):
34+
"""Read cmd from inline settings."""
35+
settings = Linter.get_view_settings(self)
36+
37+
if 'cmd' in settings:
38+
command = [settings.get('cmd')]
39+
else:
40+
command = [self.executable_path]
41+
42+
command.append('--report=checkstyle')
43+
44+
return command

messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"install": "messages/install.txt"
2+
"install": "messages/install.txt",
3+
"1.1.0": "messages/1.1.0.txt"
34
}

messages/1.1.0.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
SublimeLinter-phpcs 1.1.0
2+
---------------------------
3+
4+
This version adds support for declaring per-project linter executable files.
5+
6+
Example (*.sublime-project):
7+
{
8+
"SublimeLinter": {
9+
"linters": {
10+
"phpcs": {
11+
"cmd": "${project}/vendor/bin/phpcs"
12+
}
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)