clix/version.lua

Wed, 06 Jan 2010 03:50:37 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 06 Jan 2010 03:50:37 +0000
changeset 0
ae83411a89c9
child 27
5b58c002d6ad
permissions
-rw-r--r--

Initial commit

0
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 return function (opts, arg)
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 if #arg == 0 or opts.help then
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 return 0;
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 end
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 local conn;
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 local function on_reply(reply)
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 if not reply.error then
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 if reply.name then
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 print("Software:", reply.name);
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 end
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 if reply.version then
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 print("Version:", reply.version);
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 end
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 if reply.platform then
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 print("Platform:", reply.platform);
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 end
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 else
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 print("Error requesting version ("..(reply.condition or "unknown")..")"..(reply.text and (": "..reply.text) or ""));
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 end
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 conn:close();
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 end
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 local function on_connect(_conn)
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 conn = _conn;
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 conn:add_plugin("version");
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 conn:query_version(arg[1], on_reply);
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 end
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 clix_connect(opts, on_connect);
ae83411a89c9 Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 end

mercurial