Project

General

Profile

Download (1.91 KB) Statistics
| Branch: | Tag: | Revision:

hydrilla-builder / src / hydrilla / builder / __main__.py @ e8c1af86

1
# SPDX-License-Identifier: AGPL-3.0-or-later
2

    
3
# Command line interface of Hydrilla package builder.
4
#
5
# This file is part of Hydrilla
6
#
7
# Copyright (C) 2022 Wojtek Kosior
8
#
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU Affero General Public License as
11
# published by the Free Software Foundation, either version 3 of the
12
# License, or (at your option) any later version.
13
#
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
# GNU Affero General Public License for more details.
18
#
19
# You should have received a copy of the GNU Affero General Public License
20
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
21
#
22
#
23
# I, Wojtek Kosior, thereby promise not to sue for violation of this
24
# file's license. Although I request that you do not make use this code
25
# in a proprietary program, I am not going to enforce this in court.
26

    
27
from pathlib import Path
28

    
29
import click
30

    
31
from .build import Build
32

    
33
dir_type = click.Path(exists=True, file_okay=False, resolve_path=True)
34
index_type = click.Path(path_type=Path)
35

    
36
@click.command()
37
@click.option('-s', '--srcdir', default='.', type=dir_type,
38
              help='Source directory to build from.')
39
@click.option('-i', '--index-json', default='index.json', type=index_type,
40
              help='Path to file to be processed instead of index.json (if not absolute, resolved relative to srcdir).')
41
@click.option('-d', '--dstdir', type=dir_type, required=True,
42
              help='Destination directory to write built package files to.')
43
def preform_build(srcdir, index_json, dstdir):
44
    """
45
    Build Hydrilla package from scrdir and write the resulting files under
46
    dstdir.
47
    """
48
    build = Build(Path(srcdir), Path(index_json.decode()))
49
    build.write_package_files(Path(dstdir))
50

    
51
preform_build()
(2-2/3)