Changeset

112:757647426af2

clix.archive: Add support for paging backwards
author Kim Alvefur <zash@zash.se>
date Mon, 08 Jul 2013 12:59:34 +0200
parents 111:8c9ab9920c79
children 113:1aaf30b457a0
files clix/archive.lua
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/clix/archive.lua	Tue Jul 02 17:06:28 2013 +0200
+++ b/clix/archive.lua	Mon Jul 08 12:59:34 2013 +0200
@@ -6,6 +6,7 @@
 		return;
 	end
 
+	local reverse = opts.before;
 	if opts.start then
 		opts.start = parse_datetime(opts.start);
 	end
@@ -40,18 +41,22 @@
 			for i=1,#result do
 				print_message(result[i]);
 			end
-			if result.last then
+			if result[reverse and "first" or "last"] then
 				local fetch_next = opts.everything;
 				if opts.interactive and not fetch_next then
 					io.stderr:write "--More--"
 					fetch_next = io.read"*l" or print();
 				end
 				if fetch_next then
+					if reverse then
+						opts.before = result.first and result.first[1];
+					else
 					opts.after = result.last;
+					end
 					conn:query_archive(opts.to, opts, handle_results);
 					return
 				else
-					conn:info("Next page: --after=%s", result.last);
+					conn:info("Next page: --%s=%s", reverse and "before" or "after", result[reverse and "first" or "last"]);
 				end
 			end
 			conn:close();