From 140f13a24a7022e000b873dc4e899a323e580b90 Mon Sep 17 00:00:00 2001 From: alwin Date: Tue, 8 Mar 2022 15:33:34 +0100 Subject: [PATCH] Add debug mode --- README.md | 17 +++++++++++++++++ graphviz_py/cli.py | 7 ++++++- pyproject.toml | 4 ++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3e2a241..7ff56ce 100644 --- a/README.md +++ b/README.md @@ -69,3 +69,20 @@ Please keep in mind that graphviz-py executes all Python code in the diagram. So ## Coming soon - Compartibility with asciidoctor-diagram ([Status: Implemented & Approved, waiting for merging](https://github.com/asciidoctor/asciidoctor-diagram/pull/379)) + +## Arguments +```bash +# graphviz-py --help +usage: graphviz-py [-h] [-v] [-d] [-a ARGUMENT] [files [files ...]] + +graphviz-py diagram builder + +positional arguments: + files the paths to the graphviz-py files + +optional arguments: + -h, --help show this help message and exit + -v, --version show program's version number and exit + -d, --debug show debug information + -a ARGUMENT, --argument ARGUMENT +``` diff --git a/graphviz_py/cli.py b/graphviz_py/cli.py index a4895e5..80c71f5 100644 --- a/graphviz_py/cli.py +++ b/graphviz_py/cli.py @@ -1,5 +1,6 @@ import sys import argparse +import logging from pathlib import Path from graphviz_py.graphviz import execute_graphviz @@ -8,8 +9,9 @@ parser = argparse.ArgumentParser(description='graphviz-py diagram builder') parser.add_argument('-v', '--version', action='version', version=f'{Project.name()} version: {Project.version()}') +parser.add_argument('-d', '--debug', action='store_true', help='show debug information') parser.add_argument('-a', '--argument', action='append') -parser.add_argument('files', type=Path, nargs=argparse.ZERO_OR_MORE, help='an integer for the accumulator') +parser.add_argument('files', type=Path, nargs=argparse.ZERO_OR_MORE, help='the paths to the graphviz-py files') args, unknown = parser.parse_known_args() @@ -17,6 +19,9 @@ def main(_=None): """Process command line arguments.""" + if args.debug: + logging.getLogger().setLevel(logging.DEBUG) + file_contents = [] arguments = [] diff --git a/pyproject.toml b/pyproject.toml index 4e3187b..77aee0b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "graphviz-py" -version = "1.0.3" +version = "1.0.4" description = "Allows Python code execution inside of graphviz diagrams." authors = ["Alwin Schuster "] license = 'MPL-2.0' @@ -11,7 +11,7 @@ readme = "README.md" keywords = ["graphviz", "dot", "python", "graphviz-python", "gv"] [tool.poetry.dependencies] -python = ">=3.7.0" +python = ">=3.8.0" [tool.poetry.scripts] graphviz-py = "graphviz_py.cli:main"