Skip to content

Commit 6e42cad

Browse files
Updated dependencies and replaced unmaintained clifier dependency with click
1 parent 22b9a14 commit 6e42cad

File tree

6 files changed

+710
-692
lines changed

6 files changed

+710
-692
lines changed

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[settings]
2-
known_third_party = clifier,matplotlib,networkx,pytest
2+
known_third_party = click,matplotlib,networkx,pytest

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ repos:
44
hooks:
55
- id: seed-isort-config
66
- repo: https://github.com/pycqa/isort
7-
rev: 5.4.2
7+
rev: 5.13.2
88
hooks:
99
- id: isort
1010
- repo: https://github.com/ambv/black
11-
rev: stable
11+
rev: 24.10.0
1212
hooks:
1313
- id: black
14-
language_version: python3.8
14+
language_version: python3.12
1515
- repo: https://github.com/PyCQA/flake8
16-
rev: 3.8.3
16+
rev: 7.1.1
1717
hooks:
1818
- id: flake8

codegraph/conf/cli.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

codegraph/main.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,51 @@
1-
""" main module of testsdiffer for console (cli) usage"""
2-
import os
1+
""" main module of testsdiffer for console (cli) usage"""
2+
33
import pprint
4+
import sys
45

5-
import clifier
6+
import click
67

78
from codegraph import __version__, core
89

9-
CLI_CFG_NAME = "conf/cli.yml"
10-
11-
12-
def cli():
13-
config_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), CLI_CFG_NAME)
14-
_cli = clifier.Clifier(config_path, prog_version=__version__)
15-
parser = _cli.create_parser()
16-
args = parser.parse_args()
10+
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
11+
12+
13+
@click.command(context_settings=CONTEXT_SETTINGS)
14+
@click.version_option(version=__version__, message="CodeGraph version %(version)s")
15+
@click.argument("paths", nargs=-1, type=click.Path(exists=True))
16+
@click.option(
17+
"-o",
18+
"--object-only",
19+
is_flag=True,
20+
help="Don't visualize code dependencies as graph",
21+
)
22+
def cli(paths, object_only):
23+
"""
24+
Tool that creates a graph of code to show dependencies between code entities (methods, classes, etc.).
25+
CodeGraph does not execute code, it is based only on lex and syntax parsing.
26+
27+
PATHS: Provide path(s) to code base
28+
"""
29+
if not paths:
30+
click.echo(
31+
"Error: No paths provided. Please specify at least one path to the code base.",
32+
err=True,
33+
)
34+
sys.exit(1)
35+
36+
args = {"paths": paths, "object_only": object_only}
1737
main(args)
1838

1939

2040
def main(args):
2141
usage_graph = core.CodeGraph(args).usage_graph()
2242
pprint.pprint(usage_graph)
23-
if not args.object_only:
43+
if not args["object_only"]:
2444
# to make more quick work if not needed to visualize
2545
import codegraph.vizualyzer as vz
2646

2747
vz.draw_graph(usage_graph)
48+
49+
50+
if __name__ == "__main__":
51+
cli()

0 commit comments

Comments
 (0)