# Path: vilya/services.py



from flask.ext.script import Command, prompt
from ..services import projects, users



class CreateProjectCommand(Command):
    """Create a project"""

    def run(self):
        # TODO not tested.
        name = prompt('Name')
        owner_name = prompt('OwnerName')
        user = users.first(name=owner_name)
        if not user:
            print 'Invalid user'
            return
        data = dict(name=name,
                    owner_id=user.id)
        project = projects.create(**data)
        if project:
            print '\nProject created successfully'
            print 'Project(id=%s name=%s owner=%s)' % (project.id, project.name, user.name)
            return
        print '\nError creating project'


class DeleteProjectCommand(Command):
    """Delete a project"""

    def run(self):
        repo_name = prompt('RepoName')
        user_name, project_name = repo_name.split('/')

# Path: vilya/services.py



# Path: vilya/manage/projects.py
from flask.ext.script import Command, prompt
from ..services import projects, users




class CreateProjectCommand(Command):
    """Create a project"""

    def run(self):
        # TODO not tested.
        name = prompt('Name')
        owner_name = prompt('OwnerName')
        user = users.first(name=owner_name)
        if not user:
            print 'Invalid user'
            return
        data = dict(name=name,
                    owner_id=user.id)
        project = projects.create(**data)
        if project:
            print '\nProject created successfully'
            print 'Project(id=%s name=%s owner=%s)' % (project.id, project.name, user.name)
            return
        print '\nError creating project'


class DeleteProjectCommand(Command):
    """Delete a project"""

    def run(self):
        repo_name = prompt('RepoName')
        user_name, project_name = repo_name.split('/')

        user = users.first(name=user_name)