clix/vcard.lua

Wed, 04 Jul 2012 07:51:35 +0200

author
Kim Alvefur <zash@zash.se>
date
Wed, 04 Jul 2012 07:51:35 +0200
changeset 90
3115bd81b9de
parent 67
776d97484dc5
child 98
5ad042476235
permissions
-rw-r--r--

clix.archive: Be interactive when --interactive is set. --everything makes it page by itself.

local t_insert, t_concat = table.insert, table.concat;

return function (opts, arg)
	if opts.short_help then
		print("Fetch someones vCard or set your own");
		return;
	end
	if ((#arg == 0 and not opts.set) or opts.help) then
		return 0;
	end
	local function on_connect(conn)
		conn:add_plugin("vcard");
		if not opts.set then -- get
			conn:get_vcard(arg[1], function(vCard)
				print(vCard and vCard._text or "No vCard returned")
				conn:close();
			end);
		else
			conn:set_vcard(opts.stdin and io.stdin:read"*a"
				or (opts.file and io.open(opts.file):read"*a") or arg[1],
				function() conn:close() end)
		end
	end
	clix_connect(opts, on_connect);
end

mercurial