diff options
author | Marius <mariausol@gmail.com> | 2010-10-29 13:00:23 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2010-10-29 13:00:23 +0300 |
commit | 42c4d16ce1daa37425d12be6c87d6f64a72b5094 (patch) | |
tree | 494b8c10ccef29abe26db9acf08261ce78c16cf6 /scripts/context/lua/mtx-unzip.lua | |
parent | f56f0054360a9bdfb57de9abcf0d81a2766c22b9 (diff) | |
download | context-42c4d16ce1daa37425d12be6c87d6f64a72b5094.tar.gz |
beta 2010.10.29 11:35
Diffstat (limited to 'scripts/context/lua/mtx-unzip.lua')
-rw-r--r-- | scripts/context/lua/mtx-unzip.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/scripts/context/lua/mtx-unzip.lua b/scripts/context/lua/mtx-unzip.lua index f990f4210..85a4b9e7b 100644 --- a/scripts/context/lua/mtx-unzip.lua +++ b/scripts/context/lua/mtx-unzip.lua @@ -1,5 +1,15 @@ +if not modules then modules = { } end modules ['mtx-unzip'] = { + version = 1.001, + comment = "companion to mtxrun.lua", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + -- maybe --pattern +local format = string.format + logs.extendbanner("Simple Unzipper 0.10") messages.help = [[ @@ -36,10 +46,13 @@ function scripts.unzipper.list() if #k.filename > n then n = #k.filename end end local files, paths, compressed, uncompressed = 0, 0, 0, 0 + local template_a = "%-"..n.."s" + local template_b = "%-"..n.."s % 9i % 9i" + local template_c = "\n%-"..n.."s % 9i % 9i" for k in zipfile:files() do if k.filename:find("/$") then paths = paths + 1 - print(string.format("%s", k.filename:rpadd(n," "))) + print(format(template_a, k.filename)) else files = files + 1 local cs, us = k.compressed_size, k.uncompressed_size @@ -49,10 +62,10 @@ function scripts.unzipper.list() if us > uncompressed then uncompressed = us end - print(string.format("%s % 9i % 9i", k.filename:rpadd(n," "),cs,us)) + print(format(template_b,k.filename,cs,us)) end - end - print(string.format("\n%s % 9i % 9i", (files .. " files, " .. paths .. " directories"):rpadd(n," "),compressed,uncompressed)) + end -- check following pattern, n is not enough + print(format(template_c,files .. " files, " .. paths .. " directories",compressed,uncompressed)) end end |