Skip to content

Commit

Permalink
cmdline: add template export
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Jul 19, 2024
1 parent 5854164 commit 887fc93
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/agstoolbox/core/cmdline/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from agstoolbox.core.ags.ags_export import export_script_module_from_project
from agstoolbox.core.ags.ags_local_run import ags_editor_load, ags_editor_start, \
ags_editor_build
from agstoolbox.core.ags.ags_template import create_template_from_project
from agstoolbox.core.ags.game_project import GameProject
from agstoolbox.core.ags.get_game_projects import list_game_projects_in_dir, \
list_game_projects_in_dir_list, get_unique_game_project_in_path
Expand Down Expand Up @@ -290,9 +291,13 @@ def at_cmd_settings(args):


def at_cmd_export(args):
target_name: str = str()
prj_path: str = args.PROJECT_PATH
mod_name: str = args.MODULE_NAME
out_dir: str = args.OUT_DIR
if args.sub_export == 'script':
target_name = args.MODULE_NAME
else:
target_name = args.TEMPLATE_NAME

if not Path(prj_path).exists():
print('ERROR: Invalid project path')
Expand All @@ -310,11 +315,15 @@ def at_cmd_export(args):
print('ERROR: Invalid output dir path')
return -1

if not exists_module_in_game_project(game_project, mod_name):
print('ERROR: Module "' + mod_name + '" doesn\'t exist in Game Project')
return -1
if args.sub_export == 'script':
mod_name: str = target_name
if not exists_module_in_game_project(game_project, mod_name):
print('ERROR: Module "' + mod_name + '" doesn\'t exist in Game Project')
return -1

export_script_module_from_project(game_project, mod_name, out_dir)
export_script_module_from_project(game_project, mod_name, out_dir)
else:
create_template_from_project(game_project, target_name, out_dir)


def cmdline(show_help_when_empty: bool, program_name: str):
Expand Down Expand Up @@ -410,6 +419,14 @@ def cmdline(show_help_when_empty: bool, program_name: str):
p_ees.add_argument('OUT_DIR',
help='where to export the script module').complete = shtab.DIRECTORY

p_eet = p_ee.add_parser('template', help='export project as template')
p_eet.add_argument('PROJECT_PATH',
help='path to the project to be exported').complete = shtab.FILE
p_eet.add_argument('TEMPLATE_NAME',
help='name of the template (e.g. "template.agt")')
p_eet.add_argument('OUT_DIR',
help='where to export the template').complete = shtab.DIRECTORY

args = parser.parse_args()
if 'func' in args.__dict__:
args.func(args)
Expand Down

0 comments on commit 887fc93

Please sign in to comment.