from dataclasses import dataclass
 
# Users already loaded
already = set([
    'foo@email.com',
])
 
@dataclass
class Person:
    name: str
    email: str
    password: str
 
    @property
    def username(self):
        return self.email.split('@')[0]
 
    @property
    def full_password(self):
        if len(self.password) < 8:
            return self.password + '1234'
 
        return self.password
 
    def command(self):
        return f'goalert add-user --user {self.username} --email {self.email} --pass {self.full_password}'
 
 
def _parse_line(line):
    line = line.strip()
    results = [i.strip() for i in line.split('\t')]
    name, role, email, password = results
    return Person(_capitalize_name(name), email.lower(), password.lower())
 
 
def _capitalize_name(name):
    parts = [i.strip() for i in name.split(' ') if i.strip()]
    return ' '.join([part.capitalize() for part in parts])
 
 
# goalert add-user --db-url $GOALERT_DB_URL --admin --user admin --email admin@example.com
 
# goalert add-user --user my-user --email my-user@email.com.br --pass user123
 
with open('./data.txt', 'r') as f:
    first = True
    diff = set()
 
    for line in f:
        if first:
            first = False
            continue
 
        person = _parse_line(line)
 
        if person.email in already:
            continue
 
        if person.password != person.full_password:
            diff.add((person.email, person.full_password))
 
        print(person.command())