sregistry/client/__init__.py
def main():
    '''main is the entrypoint to the sregistry client. The flow works to first
    to determine the subparser in use based on the command. The command then
    imports the correct main (files imported in this folder) associated with
    the action of choice. When the client is imported, it is actually importing
    a return of the function get_client() under sregistry/main, which plays
    the job of "sniffing" the environment to determine what flavor of client
    the user wants to activate. Installed within a singularity image, this
    start up style maps well to Standard Container Integration Format (SCIF)
    apps, where each client is a different entrypoint activated based on the
    environment variables.
    '''

    from sregistry.main import Client as cli
    parser = get_parser()
    subparsers = get_subparsers(parser)

    def help(return_code=0):
        '''print help, including the software version and active client 
           and exit with return code.
        '''

        version = sregistry.__version__
        name = cli.client_name

        print("\nSingularity Registry Global Client v%s [%s]" %(version, name))
        parser.print_help()
        sys.exit(return_code)
    
    # If the user didn't provide any arguments, show the full help
    if len(sys.argv) == 1:
        help()
    try:
        args = parser.parse_args()
    except:
        sys.exit(0)

    if args.debug is False:
        os.environ['MESSAGELEVEL'] = "DEBUG"

    # Show the version and exit
    if args.command == "version":
        print(sregistry.__version__)
        sys.exit(0)

    from sregistry.logger import bot

    # Does the user want a shell?
    if args.command == "add": from .add import main
    elif args.command == "backend": from .backend import main
    elif args.command == "build": from .build import main
    elif args.command == "get": from .get import main
    elif args.command == "delete": from .delete import main
    elif args.command == "inspect": from .inspect import main
    elif args.command == "images": from .images import main
    elif args.command == "labels": from .labels import main
    elif args.command == "mv": from .mv import main
    elif args.command == "push": from .push import main
    elif args.command == "pull": from .pull import main
    elif args.command == "rename": from .rename import main
    elif args.command == "rm": from .rm import main
    elif args.command == "rmi": from .rmi import main
    elif args.command == "search": from .search import main
    elif args.command == "share": from .share import main
    elif args.command == "shell": from .shell import main

    # Pass on to the correct parser
    return_code = 0
    try:
        main(args=args,
             parser=parser,
             subparser=subparsers[args.command])
        sys.exit(return_code)
    except UnboundLocalError:
        return_code = 1

    help(return_code)
def main():
    '''main is the entrypoint to the sregistry client. The flow works to first
    to determine the subparser in use based on the command. The command then
    imports the correct main (files imported in this folder) associated with
    the action of choice. When the client is imported, it is actually importing
    a return of the function get_client() under sregistry/main, which plays
    the job of "sniffing" the environment to determine what flavor of client
    the user wants to activate. Installed within a singularity image, this
    start up style maps well to Standard Container Integration Format (SCIF)
    apps, where each client is a different entrypoint activated based on the
    environment variables.
    '''

    from sregistry.main import Client as cli
    parser = get_parser()
    subparsers = get_subparsers(parser)

    def help(return_code=0):
        '''print help, including the software version and active client 
           and exit with return code.
        '''

        version = sregistry.__version__
        name = cli.client_name

        print("\nSingularity Registry Global Client v%s [%s]" %(version, name))
        parser.print_help()
        sys.exit(return_code)
    
    # If the user didn't provide any arguments, show the full help
    if len(sys.argv) == 1:
        help()
    try:
        args = parser.parse_args()
    except:
        sys.exit(0)

    if args.debug is False:
        os.environ['MESSAGELEVEL'] = "DEBUG"

    # Show the version and exit
    if args.command == "version":
        print(sregistry.__version__)
        sys.exit(0)

    from sregistry.logger import bot

    # Does the user want a shell?
    if args.command == "add": from .add import main
    elif args.command == "backend": from .backend import main
    elif args.command == "build": from .build import main
    elif args.command == "get": from .get import main
    elif args.command == "delete": from .delete import main
    elif args.command == "inspect": from .inspect import main
    elif args.command == "images": from .images import main
    elif args.command == "labels": from .labels import main
    elif args.command == "mv": from .mv import main
    elif args.command == "push": from .push import main
    elif args.command == "pull": from .pull import main
    elif args.command == "rename": from .rename import main
    elif args.command == "rm": from .rm import main
    elif args.command == "rmi": from .rmi import main
    elif args.command == "search": from .search import main
    elif args.command == "share": from .share import main
    elif args.command == "shell": from .shell import main

    # Pass on to the correct parser
    return_code = 0
    try:
        main(args=args,
             parser=parser,
             subparser=subparsers[args.command])
        sys.exit(return_code)
    except UnboundLocalError:
        return_code = 1

    help(return_code)
main is the entrypoint to the sregistry client. The flow works to first
    to determine the subparser in use based on the command. The command then
    imports the correct main (files imported in this folder) associated with
    the action of choice. When the client is imported, it is actually importing
    a return of the function get_client() under sregistry/main, which plays
    the job of "sniffing" the environment to determine what flavor of client
    the user wants to activate. Installed within a singularity image, this
    start up style maps well to Standard Container Integration Format (SCIF)
    apps, where each client is a different entrypoint activated based on the
    environment variables.