Skip to content

Commit b8b8b51

Browse files
committed
Add the clean subcommand
1 parent 44b7e73 commit b8b8b51

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/docstub/_cli.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import shutil
23
import sys
34
import time
45
from collections import Counter
@@ -369,3 +370,23 @@ def run(
369370
if allow_errors < total_errors:
370371
logger.debug("number of allowed errors %i was exceeded")
371372
sys.exit(1)
373+
374+
375+
@cli.command()
376+
@click.option("-v", "--verbose", count=True, help="Print more details (repeatable).")
377+
@click.help_option("-h", "--help")
378+
def clean(verbose):
379+
"""Clean the cache.
380+
381+
Looks for a cache directory relative to the current working directory.
382+
If one exists, remove it.
383+
"""
384+
_setup_logging(verbose=verbose)
385+
386+
path = _cache_dir_in_cwd()
387+
if path.exists():
388+
assert path.is_dir()
389+
shutil.rmtree(_cache_dir_in_cwd())
390+
logger.info("cleaned %s", path)
391+
else:
392+
logger.info("no cache to clean")

0 commit comments

Comments
 (0)