Software / code / clix
Comparison
clix.lua @ 32:cda6a004ff79
clix.lua: Report when config file couldn't be found, change name to .clixrc and comply with fd.o's base directory specifications (now usually ~/.config/.clixrc)
| author | Matthew Wild |
|---|---|
| date | Sat, 29 May 2010 20:58:27 +0100 |
| parent | 28:c2998f70dfd4 |
| child | 33:f1901c9de891 |
comparison
equal
deleted
inserted
replaced
| 31:7f649b0ba94d | 32:cda6a004ff79 |
|---|---|
| 46 return 1; | 46 return 1; |
| 47 end | 47 end |
| 48 | 48 |
| 49 local accounts = { default = {} }; | 49 local accounts = { default = {} }; |
| 50 local current_account; | 50 local current_account; |
| 51 for line in io.lines(os.getenv("HOME").."/.clix") do | 51 |
| 52 local config_path = (os.getenv("XDG_CONFIG_HOME") or (os.getenv("HOME").."/.config"); | |
| 53 local config_file, err = io.open(config_path.."/.clixrc") or io.open(config_path.."/.clix"); | |
| 54 | |
| 55 if not config_file then | |
| 56 print("Unable to open config file... looked for "..config_path.."/.clixrc"); | |
| 57 if err then print(err); end | |
| 58 os.exit(1); | |
| 59 end | |
| 60 | |
| 61 for line in config_file:lines() do | |
| 52 line = line:match("^%s*(.-)%s*$"); | 62 line = line:match("^%s*(.-)%s*$"); |
| 53 if line:match("^%[") then | 63 if line:match("^%[") then |
| 54 current_account = line:match("^%[(.-)%]"); | 64 current_account = line:match("^%[(.-)%]"); |
| 55 accounts[current_account] = {}; | 65 accounts[current_account] = {}; |
| 56 if not current_account then -- This is the first defined account | 66 if not current_account then -- This is the first defined account |