clix/version.lua

Sat, 11 Aug 2012 09:25:11 +0200

author
Kim Alvefur <zash@zash.se>
date
Sat, 11 Aug 2012 09:25:11 +0200
changeset 92
a629b953780c
parent 27
5b58c002d6ad
permissions
-rw-r--r--

clix.archive: Print a newline if reading a line fails (the user pressed ^D)

return function (opts, arg)
	if opts.short_help then
		print("Query for the software of a client/server");
		return;
	end
	if #arg == 0 or opts.help then
		return 0;
	end
	local conn;
	local function on_reply(reply)
		if not reply.error then
			if reply.name then
				print("Software:", reply.name);
			end
			if reply.version then
				print("Version:", reply.version);
			end
			if reply.platform then
				print("Platform:", reply.platform);
			end
		else
			print("Error requesting version ("..(reply.condition or "unknown")..")"..(reply.text and (": "..reply.text) or ""));
		end
		conn:close();
	end
	local function on_connect(_conn)
		conn = _conn;
		conn:add_plugin("version");
		conn:query_version(arg[1], on_reply);
	end
	clix_connect(opts, on_connect);
end

mercurial