cortav  Diff

Differences From Artifact [2aa6072a5d]:

To Artifact [6b3b695c7e]:


1
2
3
4
5
6
7


8
9
10
11
12
13
14
...
223
224
225
226
227
228
229





230
231
232
233
234
235
236
237

238
239
240
241
242
243
244
245
246
-- [ʞ] cli.lua
--  ~ lexi hale <lexi@hale.su>
--  🄯 AGPLv3
--  ? simple command line driver for the cortav library
local ct = require 'cortav'
local ss = require 'sirsem'



local default_mode = {
	['render:format'] = 'html';
	['html:gen-styles'] = true;
	['groff:color'] = true;
}

local function
................................................................................
local ok, e = true, entry_cli()
if not ok then
	local str = 'translation failure'
	if ss.exn.is(e) then
		str = e.kind.desc
	end
	local color = false





	if log:seek() == nil then
		-- this is not a very reliable heuristic for detecting
		-- attachment to a tty but it's better than nothing
		if os.getenv('COLORTERM') then
			color = true
		else
			local term = os.getenv('TERM')
			if term:find 'color' then color = true end

		end
	end
	if color then
		str = string.format('\27[1;31m%s\27[m', str)
	end
	log:write(string.format('%s: %s\n', str, e))
	os.exit(1)
end
os.exit(e)







>
>







 







>
>
>
>
>
|
|
|
|
|
|
|
|
>









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
-- [ʞ] cli.lua
--  ~ lexi hale <lexi@hale.su>
--  🄯 AGPLv3
--  ? simple command line driver for the cortav library
local ct = require 'cortav'
local ss = require 'sirsem'

local native = _G.native

local default_mode = {
	['render:format'] = 'html';
	['html:gen-styles'] = true;
	['groff:color'] = true;
}

local function
................................................................................
local ok, e = true, entry_cli()
if not ok then
	local str = 'translation failure'
	if ss.exn.is(e) then
		str = e.kind.desc
	end
	local color = false
	if native then
		if native.posix.isatty(log) then
			color = true
		end
	else
		if log:seek() == nil then
			-- this is not a very reliable heuristic for detecting
			-- attachment to a tty but it's better than nothing
			if os.getenv('COLORTERM') then
				color = true
			else
				local term = os.getenv('TERM')
				if term:find 'color' then color = true end
			end
		end
	end
	if color then
		str = string.format('\27[1;31m%s\27[m', str)
	end
	log:write(string.format('%s: %s\n', str, e))
	os.exit(1)
end
os.exit(e)