#!/usr/bin/python2
#
# Copyright (C) 2008-2018  CZ.NIC, z. s. p. o.
#
# This file is part of FRED.
#
# FRED 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.
#
# FRED 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 FRED.  If not, see <https://www.gnu.org/licenses/>.

import sys
from optparse import OptionParser

#import psyco
#psyco.full()

from fred_webadmin.controller import adif

parser = OptionParser()

parser.add_option('--nperms', action='store_true', dest='nperms',
                  help='Prints negative permission of all forms.')
parser.add_option('--nperms_distinct', action='store_true', dest='nperms_distinct',
                  help='Prints negative permission of all forms distinct and alphabetically sorted.')
parser.add_option('--nperms_for_class', action='store', type="string", dest='nperms_for_class',
                  help='Prints negative permission of specified class.')

if __name__ == '__main__':
    (options, args) = parser.parse_args()
    if options.nperms or options.nperms_distinct:
        from fred_webadmin.info import print_nperms
        print_nperms(options.nperms_distinct)
    elif options.nperms_for_class:
        from fred_webadmin.info import print_nperms_for_class
        print_nperms_for_class(options.nperms_for_class)
    else:
        root = adif.prepare_root()
        adif.runserver(root)
