|
| 1 | +"""Module for main entry point for cdevents.cli.""" |
| 2 | +import logging |
| 3 | +import logging.config |
| 4 | +from pathlib import Path |
| 5 | + |
| 6 | +import click |
| 7 | +import yaml |
| 8 | + |
| 9 | +from cdevents.cli.constants import LOGGING_CONFIGURATION_FILE |
| 10 | +from cdevents.cli.build import finished, queued, started |
| 11 | +from cdevents.cli.utils import add_disclaimer_text |
| 12 | + |
| 13 | +def configure_logging(): |
| 14 | + """Configures logging from file.""" |
| 15 | + config_file = Path(LOGGING_CONFIGURATION_FILE) |
| 16 | + logging_config = yaml.safe_load(config_file.read_text(encoding="utf8")) |
| 17 | + logging.config.dictConfig(logging_config) |
| 18 | + |
| 19 | + |
| 20 | +@click.group(help=add_disclaimer_text("""Commands Build related CloudEvent.""")) |
| 21 | +def build(): |
| 22 | + """Click group for command 'build'.""" |
| 23 | + |
| 24 | +build.add_command(finished) |
| 25 | +build.add_command(queued) |
| 26 | +build.add_command(started) |
| 27 | + |
| 28 | + |
| 29 | +# @click.group(help=add_disclaimer_text("""Commands with no interaction with hostlog.""")) |
| 30 | +# def offline(): |
| 31 | +# """Function for command group offline.""" |
| 32 | + |
| 33 | + |
| 34 | +# offline.add_command(pcap_to_hdf5) |
| 35 | +# TODO: activate line when command is implemented |
| 36 | +# offline.add_command(visualize) |
| 37 | +# offline.add_command(create_dissector) |
| 38 | +# offline.add_command(convert_to_xviz) |
| 39 | +# offline.add_command(topic_configuration) |
| 40 | + |
| 41 | + |
| 42 | +# @click.group(help=add_disclaimer_text("Commands for local web UI.")) |
| 43 | +# def web(): |
| 44 | +# """Click group for command 'web'.""" |
| 45 | + |
| 46 | + |
| 47 | +# web.add_command(web_start) |
| 48 | + |
| 49 | + |
| 50 | +@click.group( |
| 51 | + help=add_disclaimer_text( |
| 52 | + """Main entry point for cdevents client cli. |
| 53 | + Select command group from Commands. |
| 54 | + Add '--help' to see more information about each subcommand, option and argument.""" |
| 55 | + ) |
| 56 | +) |
| 57 | +def cli(): |
| 58 | + """Main method for cli.""" |
| 59 | + configure_logging() |
| 60 | + |
| 61 | + |
| 62 | +cli.add_command(build) |
| 63 | +# cli.add_command(offline) |
| 64 | +# cli.add_command(web) |
| 65 | + |
| 66 | +if __name__ == "__main__": |
| 67 | + cli() |
0 commit comments