diff options
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/base.py | 5 | ||||
| -rw-r--r-- | cli/clean.py | 12 | ||||
| -rw-r--r-- | cli/model.py | 15 |
3 files changed, 30 insertions, 2 deletions
diff --git a/cli/base.py b/cli/base.py index 2098d8d..6250192 100644 --- a/cli/base.py +++ b/cli/base.py @@ -1,5 +1,10 @@ import click +from pathlib import Path + +ROOT_PATH = Path(__file__).parents[1] +NAMES_DIR = ROOT_PATH / "names" + @click.group def cli(): diff --git a/cli/clean.py b/cli/clean.py index 09eaa41..facd576 100644 --- a/cli/clean.py +++ b/cli/clean.py @@ -1,6 +1,14 @@ -from .base import cli +import ymlstash + +from .base import cli, NAMES_DIR +from .model import Name @cli.command() def clean(): - print("Cleaning..") + stash = ymlstash.YmlStash(Name, NAMES_DIR, filter_none=True) + names = stash.list_keys() + for name in names: + obj = stash.load(name) + stash.delete(obj.domain.replace(".", "")) + stash.save(obj) diff --git a/cli/model.py b/cli/model.py new file mode 100644 index 0000000..728a9d3 --- /dev/null +++ b/cli/model.py @@ -0,0 +1,15 @@ +from dataclasses import dataclass +from typing import ClassVar, Optional + + +@dataclass +class Name: + domain: str + name: str + title: Optional[str] = None + url: Optional[str] = None + email: Optional[str] = None + github: Optional[str] = None + candidate: Optional[bool] = None + invalid: Optional[bool] = None + key: ClassVar[str] = "domain" |
