Run a method as your __main__ via decorator.

      Example::

        @shrew.cli.entrypoint
        def main(cli):
          ...

      Shorthand for::

        def main():

          cli = shrew.cli.CLI()

          ...

        if __name__ == '__main__':
          method()

def entrypoint(method, depth=1, cls=None):
    """
      Run a method as your __main__ via decorator.

      Example::

        @shrew.cli.entrypoint
        def main(cli):
          ...

      Shorthand for::

        def main():

          cli = shrew.cli.CLI()

          ...

        if __name__ == '__main__':
          method()
    """

    current_frame = inspect.currentframe(depth).f_locals

    if '__name__' in current_frame and current_frame['__name__'] == '__main__':

        if cls is None:
            cls = CLI

        method(cls())

    return method