#! /usr/bin/python3
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 2018-2025 The Uncertainty Quantification Foundation.
# License: 3-clause BSD.  The full license text is available at:
#  - https://github.com/uqfoundation/pox/blob/master/LICENSE

import pox.__main__
from pox.__main__ import *
__doc__ = pox.__main__.__doc__


if __name__=='__main__':
    import re
    import sys
    try:
        func = sys.argv[1]
    except: func = None
    if func:
        poxfuncs = [func for func in dir(pox.__main__)
                    if (not func.startswith("_") and
                        isfunction(getattr(pox.__main__, func)))]
        poxfuncs.remove("isfunction")
        func_re = re.compile(r"(\w+)\([^\)]*\)$")
        func_match = func_re.match(func)
        if func_match:
            func_name = func_match.group(1)
            if func_name not in poxfuncs:
                print("Error: unrecognised pox function '%s'" % func_name)
            else:
                try:
                    exec('print(%s)' % func)
                except:
                    print("Error: incorrect syntax '%s'\n" % func)
                    print(getattr(pox.__main__, func_name).__doc__)
        else:
            print("Error: unrecognised argument '%s'; should have the form 'func(args)'" % func)
    else: help()


# End of file 
