Re-sync with internal repository
[hiphop-php.git] / third-party / watchman / src / website / _docs / cmd.version.markdown
blob24fafde41ca474b0972de85042f039bd992649fa
1 ---
2 pageid: cmd.version
3 title: version
4 layout: docs
5 section: Commands
6 permalink: docs/cmd/version.html
7 redirect_from: docs/cmd/version/
8 ---
10 The version command will tell you the version and build information
11 for the currently running watchman service:
13 ~~~bash
14 $ watchman version
16     "version": "2.9.6",
17     "buildinfo": "git:2727d9a1e47a4a2229c65cbb2f0c7656cbd96270"
19 ~~~
21 To get the version of the client:
23 ~~~bash
24 $ watchman -v
25 2.9.8
26 ~~~
28 If the server and client versions don't match up, you should probably
29 restart your server: `watchman shutdown-server ; watchman`.
31 ### Capabilities
33 *Since 3.8.*
35 The version command can be used to check for named capabilities.
36 Capabilities make it easier to check whether the server implements
37 functionality based on the name of that function rather than by
38 having the client build up knowledge about when those functions
39 were introduced.
41 You can read more about the [available capability names](
42 /watchman/docs/capabilities.html).
44 To check whether the `relative_root` capability is supported:
46 ~~~bash
47 $ watchman -j <<< '["version", {"optional":["relative_root"]}]'
49     "version": "3.8.0",
50     "capabilities": {
51         "relative_root": true
52     }
54 ~~~
56 If the capability is not supported:
58 ~~~bash
59 $ watchman -j <<< '["version", {"optional":["will-never-exist"]}]'
61     "version": "3.8.0",
62     "capabilities": {
63         "will-never-exist": false
64     }
66 ~~~
68 To have the server generate an error response if a capability is not
69 supported:
71 ~~~bash
72 $ watchman -j <<< '["version", {"required":["will-never-exist"]}]'
74     "version": "3.8.0",
75     "capabilities": {
76         "will-never-exist": false
77     },
78     "error": "client required capability `will-never-exist` is not supported by this server"
80 ~~~
82 To require one feature and test whether some optional features are supported:
84 ~~~bash
85 $ watchman -j <<< '["version", {"required":["term-match"],"optional":["a","b"]}]'
87     "version": "3.8.0",
88     "capabilities": {
89         "a": false,
90         "b": false,
91         "term-match": true
92     }
94 ~~~
96 ### capabilityCheck
98 The **node** and **python** clients provide a `capabilityCheck` method that
99 will perform the version check above, and that also provide limited support
100 for testing capability support against older versions of the watchman server.
101 This facilitates a smoother transition from version number based checks
102 to capability named based checks.
104 In *python*:
106 ~~~python
107 import pywatchman
108 client = pywatchman.client()
109 # will throw an error if any of the required names are not supported
110 res = client.capabilityCheck(optional=['a'], required=['term-match'])
111 print res
112 # {'version': '3.8.0', 'capabilities': {'term-match': True, 'a': False}}
115 In *node*:
117 ~~~js
118 var watchman = require('fb-watchman');
119 var client = new watchman.Client();
120 client.capabilityCheck({optional:['a'], required:['term-match']},
121     function (error, resp) {
122         if (error) {
123           // error will be an Error object if any of the required named
124           // are not supported
125         }
126         console.log(resp);
127         // {'version': '3.8.0', 'capabilities': {'term-match': false, 'a': false}}
128         client.end();
129     });