« Module:LxTerm » : différence entre les versions

De Adadov.net wiki
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
local documentation = require('Module:Documentation').main
local p = {}
local p = {}


local text = [[command \
function p.main()
command2
local text = frame.args.text
command3 \
local prompt = frame.args.prompt
command4]]
 
function p.main(text)
--local text = frame.args.text
local result = ""
local result = ""
local sameCommand = false
for line in text:gmatch("[^\n]+") do
for line in text:gmatch("[^\n]+") do
--print(line)
if sameCommand then
if line:gmatch("%\\n") then
line = "> "..line
--print(line)
sameCommand = false
else
line = prompt..line
end
if line:find("\\") then
sameCommand = true
end
end
result = result..line.."\n"
end
end
mw.log(result)
return text
return text
end
end


return p
return p

Version du 5 février 2015 à 19:24

Documentation icon Documentation Module[voir] [éditer] [historique] [purger]

Ce module implémente {{LxTerm}}, il met en forme les lignes de commande et ajoute les prompt.

{{#invoke:LxTerm|main|cmdnum=1|user=root|text=test \
test2}}

Erreur Lua à la ligne 6 : Tried to read nil global frame.

{{#invoke:LxTerm|main|cmdnum=1|user=root|text=test
test2}}

Erreur Lua à la ligne 6 : Tried to read nil global frame.

{{#invoke:LxTerm|main|user=nobody|text=test2}}

Erreur Lua à la ligne 6 : Tried to read nil global frame.

{{#invoke:LxTerm|main|text=test3}}

Erreur Lua à la ligne 6 : Tried to read nil global frame.

local documentation = require('Module:Documentation').main

local p = {}

function p.main()
	local text = frame.args.text
	local prompt = frame.args.prompt
	local result = ""
	local sameCommand = false
	
	for line in text:gmatch("[^\n]+") do
		if sameCommand then
			line = "> "..line
			sameCommand = false
		else
			line = prompt..line
		end
		
		if line:find("\\") then
			sameCommand = true
		end
		result = result..line.."\n"
	end
	mw.log(result)
	return text
end

return p