-
-
Save somini/c13f73d60d3a550ffa69314048daa2ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env lua | |
local args = {...} | |
-- require "pl" | |
local path = require "pl.path" | |
local Set = require "pl.Set" | |
local dir = require "pl.dir" | |
local tablex = require "pl.tablex" | |
local lfs = require "lfs" | |
-- local print = function(...) return true end | |
local MAILROOT = mutt.get("folder") or path.expanduser("~/eMail") | |
print("Mail Root: "..MAILROOT) | |
function ismaildir(P) | |
local result = true | |
for _,dir in ipairs({"cur", "new", "tmp"}) do | |
result = result and path.isdir(path.join(P, dir)) | |
end | |
return result | |
end | |
function subdirs(P) | |
return pairs(dir.getdirectories(P)) | |
end | |
local tree = Set{} | |
if #args == 0 then | |
for _, turf_path in subdirs(MAILROOT) do | |
local turf = path.basename(turf_path) | |
print("Turf: "..turf) | |
for _, account_path in subdirs(turf_path) do | |
local account = path.basename(account_path) | |
local account_tree = {} | |
print("\tAccount: "..account) | |
for _, folder_path in subdirs(account_path) do | |
local folder = path.basename(folder_path) | |
print("\t\tFolder: "..folder) | |
if ismaildir(folder_path) then | |
local rel_path = path.join(turf,account,folder) | |
tree[turf] = true | |
tree[path.join(turf,account)] = true | |
tree[path.join(turf,account,folder)] = true | |
end | |
end | |
end | |
end | |
end | |
print(Set.values(tree)) | |
for _,mb in tablex.sortv(Set.values(tree)) do | |
mutt.command.mailboxes("+"..mb) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment