cmd新增print命令可以输出一整个文件的信息
This commit is contained in:
@@ -46,7 +46,7 @@ do--commands.help(arg)
|
|||||||
"Usage: #[lua_source_code]",
|
"Usage: #[lua_source_code]",
|
||||||
"",
|
"",
|
||||||
"print() can be used to print text into this window.",
|
"print() can be used to print text into this window.",
|
||||||
"There is a strange box.",
|
"[A secret can be found]",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
exit={
|
exit={
|
||||||
@@ -64,11 +64,17 @@ do--commands.help(arg)
|
|||||||
details={
|
details={
|
||||||
"Print a message to this window.",
|
"Print a message to this window.",
|
||||||
"",
|
"",
|
||||||
"Aliases: echo print",
|
|
||||||
"",
|
|
||||||
"Usage: echo [message]",
|
"Usage: echo [message]",
|
||||||
},
|
},
|
||||||
},print="echo",
|
},
|
||||||
|
print={
|
||||||
|
description="Print a file to this window.",
|
||||||
|
details={
|
||||||
|
"Print a file to this window.",
|
||||||
|
"",
|
||||||
|
"Usage: print [filename]",
|
||||||
|
},
|
||||||
|
},
|
||||||
url={
|
url={
|
||||||
description="Attempt to open a URL with your device.",
|
description="Attempt to open a URL with your device.",
|
||||||
details={
|
details={
|
||||||
@@ -213,6 +219,7 @@ do--commands.help(arg)
|
|||||||
"#",
|
"#",
|
||||||
"exit",
|
"exit",
|
||||||
"echo",
|
"echo",
|
||||||
|
"print",
|
||||||
"url",
|
"url",
|
||||||
"tree",
|
"tree",
|
||||||
"del",
|
"del",
|
||||||
@@ -275,6 +282,26 @@ function commands.echo(str)
|
|||||||
outputBox:push(str)
|
outputBox:push(str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function commands.print(name)
|
||||||
|
if name~=""then
|
||||||
|
local info=love.filesystem.getInfo(name)
|
||||||
|
if info then
|
||||||
|
if info.type=="file"then
|
||||||
|
log{COLOR.lC,"/* "..name.." */"}
|
||||||
|
for l in love.filesystem.lines(name)do
|
||||||
|
log(l)
|
||||||
|
end
|
||||||
|
log{COLOR.lC,"/* END */"}
|
||||||
|
else
|
||||||
|
log("Unprintable item: %s (%s)"):format(name,info.type)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
log{C.R,"No file called '"..name.."'"}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
log{C.water,"Usage: del [filename]"}
|
||||||
|
end
|
||||||
|
end
|
||||||
function commands.url(url)
|
function commands.url(url)
|
||||||
if url~=""then
|
if url~=""then
|
||||||
local res,err=pcall(love.system.openURL,url)
|
local res,err=pcall(love.system.openURL,url)
|
||||||
|
|||||||
Reference in New Issue
Block a user