File size: 1,664 Bytes
a164e13 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# Copyright (C) 2024 Charles O. Goddard
#
# This software is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
import logging
import click
import yaml
from mergekit.config import MergeConfiguration
from mergekit.merge import run_merge
from mergekit.options import MergeOptions, add_merge_options
@click.command("mergekit-yaml")
@click.argument("config_file")
@click.argument("out_path")
@click.option(
"--verbose", "-v", type=bool, default=False, is_flag=True, help="Verbose logging"
)
@add_merge_options
def main(
merge_options: MergeOptions,
config_file: str,
out_path: str,
verbose: bool,
):
logging.basicConfig(level=logging.INFO if verbose else logging.WARNING)
with open(config_file, "r", encoding="utf-8") as file:
config_source = file.read()
merge_config: MergeConfiguration = MergeConfiguration.model_validate(
yaml.safe_load(config_source)
)
run_merge(
merge_config,
out_path,
options=merge_options,
config_source=config_source,
)
if __name__ == "__main__":
main()
|