-
Notifications
You must be signed in to change notification settings - Fork 0
/
familytree
executable file
·37 lines (28 loc) · 1006 Bytes
/
familytree
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
import gc
import typer
from src.familytree import FamilyTree
from src.familytree import RelationType
# Command line Interface requirements
app = typer.Typer()
add_app = typer.Typer()
app.add_typer(add_app, name = "add")
# Instantiating familytree
ft = FamilyTree()
@add_app.command("person")
def add_person(person: str):
ft.add_person(person)
@add_app.command("relationship")
def add_relationship(relation: str, relation_type: RelationType):
ft.add_relationship(relation, relation_type)
@app.command("connect")
def connect_people(person: str , relation: str = typer.Option(...), of: str = typer.Option(...)):
ft.connect_people(of, person, relation)
@app.command("count")
def count_relation(person: str, relation: str = typer.Option(...), all: bool = typer.Option(False)):
print("No of {}s of {}: {}".format(relation, person, ft.count_relation(person, relation, all=all)))
@app.command("clear")
def clear():
ft.clear()
if __name__ == "__main__":
app()