Skip to content

Commit

Permalink
feat: add subcommand tool-love-zip #37
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoDornelles committed Oct 4, 2024
1 parent a5db785 commit f28ae6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/cli/commands/tools.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local zeebo_compiler = require('src/lib/cli/compiler')
local zeebo_bundler = require('src/lib/cli/bundler')
local zeebo_fs = require('src/lib/cli/fs')

local function bundler(args)
local path, file = args.file:match("(.-)([^/\\]+)$")
Expand All @@ -11,7 +12,15 @@ local function compiler(args)
end

local function love_zip(args)
return false, 'not implemented!'
os.execute('mkdir -p '..args.dist..'_love')
os.execute('mv '..args.path..'/* '..args.dist..'_love 2> /dev/null')
local zip_pid = io.popen('cd '..args.dist..'_love && zip -9 -r Game.love .')
local stdout = zip_pid:read('*a')
local ok = zip_pid:close()
zeebo_fs.move(args.dist..'_love/Game.love', args.dist..'Game.love')
zeebo_fs.clear(args.dist..'_love')
os.remove(args.dist..'_love')
return ok, stdout
end

local function love_exe(args)
Expand Down
2 changes: 1 addition & 1 deletion src/cli/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ local command = zeebo_argparse.from(arg)
--
.add_subcommand('tool-love-zip', commands_tools)
.add_next_value('path', {required=true})
.add_option_get('dist', {required=true})
.add_option_get('dist', {default='./dist/'})
--
.add_subcommand('tool-love-exe', commands_tools)
.add_next_value('file', {required=true})
Expand Down

0 comments on commit f28ae6e

Please sign in to comment.