Skip to content
This repository has been archived by the owner on Feb 20, 2018. It is now read-only.

Commit

Permalink
install_demos and a small fix with fs
Browse files Browse the repository at this point in the history
  • Loading branch information
egordorichev committed Sep 15, 2017
1 parent eeb29d6 commit 3832766
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 40 deletions.
1 change: 1 addition & 0 deletions neko.n8
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function _init()
mkdir=mkdir,
rm=rm,
shutdown=shutdown,
install_demos=install_demos,
reboot=reboot,
load=load,
run=run,
Expand Down
1 change: 1 addition & 0 deletions src/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ function createSandbox(lang)
minify = commands.minify,
version = commands.version,
pwd = commands.pwd,
install_demos = commands.installDemos,

pairs = pairs,
ipairs = ipairs,
Expand Down
51 changes: 33 additions & 18 deletions src/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,29 +153,43 @@ function commands.help(a)
api.color(7)
api.print("https://github.com/egordorichev/neko8")
api.print("")
api.print("Command Description")
api.print("------- -----------")
api.print("ls list files")
api.print("new new cart")
api.print("cd change dir")
api.print("mkdir create dir")
api.print("rm delete file")
api.print("load load cart")
api.print("run run cart")
api.print("reboot reboots neko8")
api.print("shutdown shutdowns neko8")
api.print("save save cart")
api.print("edit opens editor")
api.print("cls clear screen")
api.print("folder open working folder on host os")
api.print("pwd display working directory")
api.print("version prints neko8 version")
api.print("Command Description")
api.print("------- -----------")
api.print("install_demos intall default demos")
api.print("ls list files")
api.print("new new cart")
api.print("cd change dir")
api.print("mkdir create dir")
api.print("rm delete file")
api.print("load load cart")
api.print("run run cart")
api.print("reboot reboots neko8")
api.print("shutdown shutdowns neko8")
api.print("save save cart")
api.print("edit opens editor")
api.print("cls clear screen")
api.print("folder open working folder on host os")
api.print("pwd display working directory")
api.print("version prints neko8 version")
else
-- TODO
api.print("subject " .. a[1] .. " is not found")
end
end

function commands.installDemos()
love.filesystem.createDirectory("/demos")
local demos = love.filesystem.getDirectoryItems("/demos")

for i, f in ipairs(demos) do
local n = "demos/" .. f

love.filesystem.write(
n, love.filesystem.read(n)
)
end
end

function commands.edit()
neko.cart = nil
api.camera(0, 0)
Expand Down Expand Up @@ -382,7 +396,8 @@ function commands.rm(a)

local file = resolveFile(a[1], neko.currentDirectory)

if not love.filesystem.exists(file) then
if not love.filesystem.exists(file)
or not isVisible(a[1], neko.currentDirectory) then
api.print(
"no such file", nil, nil, 14
)
Expand Down
24 changes: 2 additions & 22 deletions src/neko8.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,13 @@ function neko.init()
initPalette()
initApi()

local files = love.filesystem.getDirectoryItems("/")
local count = 0

for i, f in ipairs(files) do
if isVisible(f, "/") then
count = count + 1
end
end

if count == 0 then
log.info("installing core and demos")
if not isVisible("neko.n8", "/") then
log.info("installing core")

love.filesystem.write(
"neko.n8",
love.filesystem.read("neko.n8")
)

love.filesystem.createDirectory("/demos")
local demos = love.filesystem.getDirectoryItems("/demos")

for i, f in ipairs(demos) do
local n = "demos/" .. f

love.filesystem.write(
n, love.filesystem.read(n)
)
end
end

editors = require "editors"
Expand Down

0 comments on commit 3832766

Please sign in to comment.