From f28ae6efd5882d1e7ad26e249de53df04536c534 Mon Sep 17 00:00:00 2001 From: RodrigoDornelles Date: Fri, 4 Oct 2024 17:52:46 -0300 Subject: [PATCH] feat: add subcommand tool-love-zip #37 --- src/cli/commands/tools.lua | 11 ++++++++++- src/cli/main.lua | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cli/commands/tools.lua b/src/cli/commands/tools.lua index 96464be..0c13119 100644 --- a/src/cli/commands/tools.lua +++ b/src/cli/commands/tools.lua @@ -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("(.-)([^/\\]+)$") @@ -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) diff --git a/src/cli/main.lua b/src/cli/main.lua index 1286edd..94b3ee7 100644 --- a/src/cli/main.lua +++ b/src/cli/main.lua @@ -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})