Coverage for dirimport/_cli.py: 62%
36 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-05 14:22 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-05 14:22 +0000
1import os
3import click
5from . import gen
6from ._version import VERSION
9@click.group(invoke_without_command=True)
10@click.version_option(VERSION)
11@click.pass_context
12def cli(ctx):
13 if ctx.invoked_subcommand is None:
14 print(ctx.get_help())
17@cli.command("diff")
18@click.argument("path", type=click.Path(exists=True, dir_okay=True, file_okay=False))
19@click.option("--filename", default="__init__.py")
20def diffcmd(path, filename):
21 data = gen.dig(path)
22 click.echo("\n".join(f.rstrip() for f in gen.diff(data, path, filename)))
25@cli.command("generate")
26@click.argument("path", type=click.Path(exists=True, dir_okay=True, file_okay=False))
27@click.option("--filename", default="__init__.py")
28def generatecmd(path, filename):
29 data = gen.dig(path)
30 gen.generate(data, path, filename)
33@cli.command()
34@click.argument("path", type=click.Path(exists=True, dir_okay=True, file_okay=False))
35def dig(path):
36 data = gen.dig(path)
37 print(data)
40@cli.command("eval")
41@click.argument("path", type=click.Path(exists=True, dir_okay=True, file_okay=False))
42@click.argument("expr")
43def evalcmd(path, expr):
44 bn = os.path.basename(path)
45 globals()[bn] = gen.importall(path)
46 click.echo(eval(expr))
49if __name__ == "__main__": 49 ↛ 50line 49 didn't jump to line 50 because the condition on line 49 was never true
50 cli()