add clean dev command

This commit is contained in:
Izalia Mae 2024-04-01 07:18:10 -04:00
parent c200c295e7
commit 673175b80b

View file

@ -1,5 +1,6 @@
import click import click
import platform import platform
import shutil
import subprocess import subprocess
import sys import sys
import time import time
@ -46,13 +47,14 @@ def cli_install():
@cli.command('lint') @cli.command('lint')
@click.argument('path', required = False, default = 'relay') @click.argument('path', required = False, type = Path, default = REPO.joinpath('relay'))
@click.option('--strict', '-s', is_flag = True, help = 'Enable strict mode for mypy') @click.option('--strict', '-s', is_flag = True, help = 'Enable strict mode for mypy')
@click.option('--watch', '-w', is_flag = True, @click.option('--watch', '-w', is_flag = True,
help = 'Automatically, re-run the linters on source change') help = 'Automatically, re-run the linters on source change')
def cli_lint(path: str, strict: bool, watch: bool) -> None: def cli_lint(path: Path, strict: bool, watch: bool) -> None:
flake8 = [sys.executable, '-m', 'flake8', path] path = path.expanduser().resolve()
mypy = [sys.executable, '-m', 'mypy', path] flake8 = [sys.executable, '-m', 'flake8', str(path)]
mypy = [sys.executable, '-m', 'mypy', str(path)]
if strict: if strict:
mypy.append('--strict') mypy.append('--strict')
@ -68,6 +70,24 @@ def cli_lint(path: str, strict: bool, watch: bool) -> None:
subprocess.run(mypy) subprocess.run(mypy)
@cli.command('clean')
def cli_clean():
dirs = {
'dist',
'build',
'dist-pypi'
}
for directory in dirs:
shutil.rmtree(directory, ignore_errors = True)
for path in REPO.glob('*.egg-info'):
shutil.rmtree(path)
for path in REPO.glob('*.spec'):
path.unlink()
@cli.command('build') @cli.command('build')
def cli_build(): def cli_build():
with TemporaryDirectory() as tmp: with TemporaryDirectory() as tmp: