aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/builder
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla/builder')
-rw-r--r--src/hydrilla/builder/__main__.py24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/hydrilla/builder/__main__.py b/src/hydrilla/builder/__main__.py
index 5b98202..32ac2d9 100644
--- a/src/hydrilla/builder/__main__.py
+++ b/src/hydrilla/builder/__main__.py
@@ -30,32 +30,22 @@ import click
from .build import Build
-def validate_dir_path(ctx, param, value):
- path = Path(value)
- if path.is_dir():
- return path.resolve()
-
- raise click.BadParameter(f'{param.human_readable_name} must be a directory path')
-
-def validate_path(ctx, param, value):
- return Path(value)
+dir_type = click.Path(exists=True, file_okay=False, resolve_path=True)
+index_type = click.Path(path_type=Path)
@click.command()
-@click.option('-s', '--srcdir', default='.', type=click.Path(),
- callback=validate_dir_path,
+@click.option('-s', '--srcdir', default='.', type=dir_type,
help='Source directory to build from.')
-@click.option('-i', '--index-json', default='index.json', type=click.Path(),
- callback=validate_path,
+@click.option('-i', '--index-json', default='index.json', type=index_type,
help='Path to file to be processed instead of index.json (if not absolute, resolved relative to srcdir).')
-@click.option('-d', '--dstdir', type=click.Path(), required=True,
- callback=validate_dir_path,
+@click.option('-d', '--dstdir', type=dir_type, required=True,
help='Destination directory to write built package files to.')
def preform_build(srcdir, index_json, dstdir):
"""
Build Hydrilla package from scrdir and write the resulting files under
dstdir.
"""
- build = Build(srcdir, index_json)
- build.write_package_files(dstdir)
+ build = Build(Path(srcdir), Path(index_json.decode()))
+ build.write_package_files(Path(dstdir))
preform_build()