Add env.cliprint
This commit is contained in:
parent
a3d9bef8aa
commit
2909fb8c7d
@ -14,7 +14,6 @@ local function cmd(args)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if args[2] == nil then
|
if args[2] == nil then
|
||||||
print("No name given")
|
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
entry.attrs.name = args[2]
|
entry.attrs.name = args[2]
|
||||||
@ -35,7 +34,7 @@ local function cmd(args)
|
|||||||
entry.parent = entries
|
entry.parent = entries
|
||||||
table.insert(entries.children,entry)
|
table.insert(entries.children,entry)
|
||||||
env.changed = true
|
env.changed = true
|
||||||
print(entry.attrs.id)
|
env.cliprint(entry.attrs.id)
|
||||||
return entry
|
return entry
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ local function cmd(args)
|
|||||||
entries = env.xmlFindTags(entries,"entry")
|
entries = env.xmlFindTags(entries,"entry")
|
||||||
for i,entry in pairs(entries) do
|
for i,entry in pairs(entries) do
|
||||||
if (entry.attrs.removed ~= "true") then
|
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)
|
table.insert(rtn,entry)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ local function cmd(args)
|
|||||||
if v.attrs.id == args[2] then
|
if v.attrs.id == args[2] then
|
||||||
for i,v in pairs(env.xmlFindTags(v,"fields")[1].children) do
|
for i,v in pairs(env.xmlFindTags(v,"fields")[1].children) do
|
||||||
if v.attrs.name == args[3] then
|
if v.attrs.name == args[3] then
|
||||||
print(v.children[1].text)
|
env.cliprint(v.children[1].text)
|
||||||
return v.children[1].text
|
return v.children[1].text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ local function cmd(args)
|
|||||||
if v.attrs.id == args[2] then
|
if v.attrs.id == args[2] then
|
||||||
for i,v in pairs(env.xmlFindTags(v,"fields")[1].children) do
|
for i,v in pairs(env.xmlFindTags(v,"fields")[1].children) do
|
||||||
if v.attrs.name == args[3] then
|
if v.attrs.name == args[3] then
|
||||||
print(v.attrs.type)
|
env.cliprint(v.attrs.type)
|
||||||
return v.attrs.type
|
return v.attrs.type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ local function cmd(args)
|
|||||||
for i,v in pairs(entries.children) do
|
for i,v in pairs(entries.children) do
|
||||||
if v.attrs.id == args[2] and not v.attrs.deleted then
|
if v.attrs.id == args[2] and not v.attrs.deleted then
|
||||||
for i,v in pairs(env.xmlFindTags(v,"fields")[1].children) do
|
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)
|
table.insert(rtn,v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
env = {}
|
env = {}
|
||||||
|
env.cli = true
|
||||||
|
|
||||||
function env.loop()
|
function env.loop()
|
||||||
local command = env.stringSplit(io.read()," ",3,"\\")
|
local command = env.stringSplit(io.read()," ",3,"\\")
|
||||||
@ -83,3 +84,9 @@ function env.padNumber(nr,len)
|
|||||||
end
|
end
|
||||||
return nr
|
return nr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function env.cliprint(text)
|
||||||
|
if env.cli == true then
|
||||||
|
print(text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user