def main():
    '''main entry'''

    cli = docker.from_env()

    try:
        opts, args = getopt.gnu_getopt(sys.argv[1:], "pcv", ["pretty", "compose"])
    except getopt.GetoptError as _:
        print("Usage: docker-parse [--pretty|-p|--compose|-c] [containers]")
        sys.exit(2)

    if len(args) == 0:
        containers = cli.containers.list(all=True)
    else:
        containers = map(lambda nm: cli.containers.get(nm), args)

    as_compose = False
    pretty = False
    for opt, _ in opts:
        if opt == '-v':
            print(__version__)
            sys.exit()
        elif opt == '-p' or opt == '--pretty':
            pretty = True
            break
        elif opt == '-c' or opt == '--compose':
            as_compose = True
            break

    for container in containers:
	info = container.attrs

        # diff with image info to reduce information
        image_info = cli.images.get(info['Config']['Image']).attrs

        if as_compose:
            output_compose(info, image_info)
        else:
            output_command(info, image_info, pretty)
def main ( ) : cli = docker . from_env ( ) try : opts , args = getopt . gnu_getopt ( sys . argv [ 1 : ] , "pcv" , [ "pretty" , "compose" ] ) except getopt . GetoptError as _ : print ( "Usage: docker-parse [--pretty|-p|--compose|-c] [containers]" ) sys . exit ( 2 ) if len ( args ) == 0 : containers = cli . containers . list ( all = True ) else : containers = map ( lambda nm : cli . containers . get ( nm ) , args ) as_compose = False pretty = False for opt , _ in opts : if opt == '-v' : print ( __version__ ) sys . exit ( ) elif opt == '-p' or opt == '--pretty' : pretty = True break elif opt == '-c' or opt == '--compose' : as_compose = True break for container in containers : info = container . attrs image_info = cli . images . get ( info [ 'Config' ] [ 'Image' ] ) . attrs if as_compose : output_compose ( info , image_info ) else : output_command ( info , image_info , pretty )
main entry