76 lines
1.9 KiB
Python
76 lines
1.9 KiB
Python
"""
|
|
cli.conv.assets - Vhex asset converter user interface
|
|
"""
|
|
import os
|
|
|
|
from core.logger import log
|
|
from core.conv import assets_generate
|
|
|
|
__all__ = [
|
|
'assets_conv_cli'
|
|
]
|
|
|
|
#---
|
|
# Internals
|
|
#---
|
|
|
|
__HELP__ = """vxsdk-converter-asset
|
|
Convert all assets file in the project directory.
|
|
|
|
USAGE:
|
|
vxsdk conv-asset [project path] [OPTIONS]
|
|
|
|
DESCRIPTION:
|
|
Convert all assets file in the asset directory. This part of the converter
|
|
module will scan the provided folder (or the current working directory) and
|
|
will try to find all `vxconv.txt` file, which describe all assets that
|
|
should be converted.
|
|
|
|
If no argument is provided, then the current working directory is used as
|
|
asset prefix and a storag for all generated source file. You can modify
|
|
this behaviour using OPTIONS.
|
|
|
|
For more information about the `vxconv.txt` in the wiki.
|
|
|
|
OPTIONS:
|
|
-o <output prefix> The prefix for source file that will be generated
|
|
-h, --help Display this help
|
|
"""
|
|
|
|
#---
|
|
# Public
|
|
#---
|
|
|
|
def assets_conv_cli(argv):
|
|
"""Process CLI arguments"""
|
|
# check obvious flags
|
|
if '-h' in argv or '--help' in argv:
|
|
log.user(__HELP__)
|
|
return 0
|
|
|
|
# fetch user indication
|
|
manual_output = False
|
|
prefix_output = None
|
|
prefix_asset = None
|
|
for arg in argv:
|
|
if arg == '-o':
|
|
manual_output = True
|
|
continue
|
|
if manual_output:
|
|
prefix_output = arg
|
|
continue
|
|
if prefix_asset:
|
|
log.warn(f"warning: previous path ({prefix_asset}) dropped")
|
|
prefix_asset = arg
|
|
|
|
# check indication
|
|
if not prefix_asset:
|
|
prefix_asset = os.getcwd()
|
|
if not prefix_output:
|
|
prefix_output = os.getcwd()
|
|
prefix_asset = os.path.abspath(prefix_asset)
|
|
prefix_output = os.path.abspath(prefix_output)
|
|
|
|
# generate asset information
|
|
return assets_generate(prefix_asset, prefix_output, True)
|