#!/usr/bin/env python
import sys
import elpotrero.lib.util as elutil
import configurationvalues as confvals


def help():
    _HELPMSG="""
-h,   --help                            this help message

-t,   --test                            run a test

-p,   --projectpath                     display project path

-k [KEYNAME], --key [KEYNAME]           retrieve the value in basic_configuration

-kl [KEYNAME], --layoutkey [KEYNAME]    retrieve the value in filelayout

-ak,  --allkeys                         show all keys

"""
    return _HELPMSG


def main(args):

    if elutil.findflags('-h', '--help', args):
        print help()

    isTest = elutil.findflags('-t', '--test', args)

    if isTest:
        print confvals.getbranch()
        print confvals._here()
        print confvals.getprojectpath()
        print confvals.getfilelayoutpath()
        print confvals.getconfigurationpath('configuration\.branch')
        print confvals.getconfigurationpath('configuration\.basic')
        print confvals.getconfigvalue('project')
        print confvals.getconfigvalue('user')
        print confvals.getconfigvalue('user', False)

    key = elutil.findargs('-k', '--key', args)
    if key is not None:
        print confvals.getconfigvalue(key)

    key = elutil.findargs('-kl', '--layoutkey', args)
    if key is not None:
        print confvals.getlayoutvalue(key)

    if elutil.findflags('-ak', '--allkeys', args):
        print confvals.getconfigkeys()

    if elutil.findflags('-p', '--projectpath', args):
        print confvals.getprojectpath()





if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))
