Skip to content

Commit

Permalink
Improve VRAD argument checks.
Browse files Browse the repository at this point in the history
This makes #810 have a better error message.
Also add a usage text if no arguments are given.
  • Loading branch information
TeamSpen210 committed Jan 20, 2018
1 parent c87e3a8 commit 23e8ae7
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/vrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,17 +914,29 @@ def run_vrad(args):

def main(argv):
LOGGER.info('BEE2 VRAD hook started!')

args = " ".join(argv)
fast_args = argv[1:]
full_args = argv[1:]

if not fast_args:
# No arguments!
LOGGER.info(
'No arguments!\n'
"The BEE2 VRAD takes all the regular VRAD's "
'arguments, with some extra arguments:\n'
'-force_peti: Force enabling map conversion. \n'
"-force_hammer: Don't convert the map at all.\n"
"If not specified, the map name must be \"preview.bsp\" to be "
"treated as PeTI."
)
sys.exit()

# The path is the last argument to vrad
# P2 adds wrong slashes sometimes, so fix that.
fast_args[-1] = path = os.path.normpath(argv[-1])

LOGGER.info("Map path is " + path)
if path == "":
raise Exception("No map passed!")

load_config()

Expand Down Expand Up @@ -952,6 +964,11 @@ def main(argv):
if not path.endswith(".bsp"):
path += ".bsp"

if not os.path.exists(path):
raise ValueError('"{}" does not exist!'.format(path))
if not os.path.isfile(path):
raise ValueError('"{}" is not a file!'.format(path))

# If VBSP thinks it's hammer, trust it.
if CONF.bool('is_hammer', False):
is_peti = edit_args = False
Expand Down

0 comments on commit 23e8ae7

Please sign in to comment.