#!/usr/bin/python
# -*- coding: latin-1 -*-

# Copyright 2012 Gabriel Oliverio

# This file is part of Seeti.

# Seeti is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Seeti is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Seeti.  If not, see <http://www.gnu.org/licenses/>.

import sys
import os

from Seeti.core import arg_parsers
from Seeti.core.storage import Manager

if __name__ == "__main__":
    args = vars(arg_parsers.parser.parse_args())

    manager = Manager()
    
    try:
        if args.get('init'):
            manager.init()
            print 'Seeti was successfully initialized!'
        elif args.get('start'):
            manager.start()
            print 'Seeti started!'
        elif args.get('stop'):
            manager.stop()
            print 'Seeti stopped!'
        elif args.get('report'):
            print manager.report()
        elif args.get('status'):
            print manager.get_status().capitalize()
        elif args.get('close'):
            manager.close()
            print 'Seeti closed!'
        elif args.get('restart'):
            manager.restart()
            print 'Seeti restarted!'
        elif args.get('open'):
            manager.open()
            print 'Seeti opened!'
        elif args.get('remove'):
            manager.remove()
            print 'Seeti removed the .seeti file successfully!'
    except NotImplementedError as e:
        print "Command not implemented yet."
    except RuntimeError as e:
        print e
    except Exception as e:
        print e