summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2024-05-09 13:20:47 +0200
committerYuval Adam <_@yuv.al>2024-05-10 12:55:22 +0200
commit233d0ac7057aad3f2ea8ad4dd24697c868c7a19a (patch)
tree83efeda73c1a5848d831cb85a2c050bf77ba95c6 /cli
parenta234056e66407a99b966623622cc495e57aee3e3 (diff)
Migrate all names to canonical doma.in.yml
Diffstat (limited to 'cli')
-rw-r--r--cli/base.py5
-rw-r--r--cli/clean.py12
-rw-r--r--cli/model.py15
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"