Fail early on invalid save locations
Currently the Render command expects either no save option or a file path. No save option defaults to stdout, a file path writes to the specified file. If a directory is specified no error is thrown until rendering is complete, by performing save location validation early Pegleg will now fail early. Change-Id: If75655e240c0ecbda00ea591e948e71010b4521d Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
This commit is contained in:
parent
e4ff07c793
commit
cb3046ee53
@ -177,7 +177,7 @@ def show(*, save_location, site_name):
|
|||||||
|
|
||||||
|
|
||||||
@site.command('render', help='Render a site through the deckhand engine.')
|
@site.command('render', help='Render a site through the deckhand engine.')
|
||||||
@utils.SAVE_LOCATION_OPTION
|
@utils.SAVE_FILE_OPTION
|
||||||
@click.option(
|
@click.option(
|
||||||
'-v',
|
'-v',
|
||||||
'--validate',
|
'--validate',
|
||||||
|
@ -95,9 +95,20 @@ SAVE_LOCATION_OPTION = click.option(
|
|||||||
'-o', # DEPRECATED
|
'-o', # DEPRECATED
|
||||||
'--output', # DEPRECATED
|
'--output', # DEPRECATED
|
||||||
'save_location',
|
'save_location',
|
||||||
|
type=click.Path(writable=True),
|
||||||
help='Where to save the output. Defaults to stdout. '
|
help='Where to save the output. Defaults to stdout. '
|
||||||
'-o (--output) is deprecated and will be removed.')
|
'-o (--output) is deprecated and will be removed.')
|
||||||
|
|
||||||
|
SAVE_FILE_OPTION = click.option(
|
||||||
|
'-s',
|
||||||
|
'--save-location',
|
||||||
|
'-o', # DEPRECATED
|
||||||
|
'--output', # DEPRECATED
|
||||||
|
'save_location',
|
||||||
|
type=click.Path(dir_okay=False, file_okay=True, writable=True),
|
||||||
|
help='File to save the output. Defaults to stdout. '
|
||||||
|
'-o (--output) is deprecated and will be removed.')
|
||||||
|
|
||||||
REPOSITORY_CLONE_PATH_OPTION = click.option(
|
REPOSITORY_CLONE_PATH_OPTION = click.option(
|
||||||
'-p',
|
'-p',
|
||||||
'--clone-path',
|
'--clone-path',
|
||||||
|
Loading…
Reference in New Issue
Block a user