Add env.cliprint

This commit is contained in:
Fierelier 2024-08-12 01:24:01 +00:00
parent a3d9bef8aa
commit 2909fb8c7d
6 changed files with 12 additions and 6 deletions

View File

@ -14,7 +14,6 @@ local function cmd(args)
end
end
if args[2] == nil then
print("No name given")
os.exit(1)
end
entry.attrs.name = args[2]
@ -35,7 +34,7 @@ local function cmd(args)
entry.parent = entries
table.insert(entries.children,entry)
env.changed = true
print(entry.attrs.id)
env.cliprint(entry.attrs.id)
return entry
end

View File

@ -4,7 +4,7 @@ local function cmd(args)
entries = env.xmlFindTags(entries,"entry")
for i,entry in pairs(entries) do
if (entry.attrs.removed ~= "true") then
print(entry.attrs.id .. " " ..entry.attrs.date.. " " ..entry.attrs.name)
env.cliprint(entry.attrs.id .. " " ..entry.attrs.date.. " " ..entry.attrs.name)
table.insert(rtn,entry)
end
end

View File

@ -4,7 +4,7 @@ local function cmd(args)
if v.attrs.id == args[2] then
for i,v in pairs(env.xmlFindTags(v,"fields")[1].children) do
if v.attrs.name == args[3] then
print(v.children[1].text)
env.cliprint(v.children[1].text)
return v.children[1].text
end
end

View File

@ -4,7 +4,7 @@ local function cmd(args)
if v.attrs.id == args[2] then
for i,v in pairs(env.xmlFindTags(v,"fields")[1].children) do
if v.attrs.name == args[3] then
print(v.attrs.type)
env.cliprint(v.attrs.type)
return v.attrs.type
end
end

View File

@ -4,7 +4,7 @@ local function cmd(args)
for i,v in pairs(entries.children) do
if v.attrs.id == args[2] and not v.attrs.deleted then
for i,v in pairs(env.xmlFindTags(v,"fields")[1].children) do
print(v.attrs.name)
env.cliprint(v.attrs.name)
table.insert(rtn,v)
end
end

View File

@ -1,5 +1,6 @@
math.randomseed(os.time())
env = {}
env.cli = true
function env.loop()
local command = env.stringSplit(io.read()," ",3,"\\")
@ -83,3 +84,9 @@ function env.padNumber(nr,len)
end
return nr
end
function env.cliprint(text)
if env.cli == true then
print(text)
end
end