def main():
    try:
        COMMAND = os.path.basename(sys.argv[0])
        args = sys.argv[1:]
        if COMMAND == 'queueit':
            if len(sys.argv) == 1:
                print "Usage:"
                print "%s q-get" % COMMAND
                print "%s q-put" % COMMAND
                print "%s q-kick" % COMMAND
                print "%s q-stat" % COMMAND
                print "%s q-wrapper" % COMMAND
                print "%s q-wrapper-batch" % COMMAND
                print "%s q-wrapper-with-stats" % COMMAND
                print "%s q-peek" % COMMAND
                print "%s q-peek-ready" % COMMAND
                print "%s q-peek-delayed" % COMMAND
                print "%s q-peek-buried" % COMMAND
                sys.exit(1)
            else:
                COMMAND = os.path.basename(sys.argv[1])
                args = sys.argv[2:]


        if COMMAND == 'q-get':
            if not len(args) == 1:
                print "Usage: %s <queue>" % (COMMAND)
                sys.exit(1)
            qget(args[0])
        elif COMMAND == 'q-put':
            if len(args) == 1:
                qput(args[0], [sys.stdin.read(),])
            elif len(args) > 1:
                qput(args[0], args[1:])
            else:
                print "Usage: %s <queue> [<message>, <message>, ...]\n Message body could be sent trough STDIN" % (COMMAND )
                sys.exit(1)
        elif COMMAND == 'q-kick':
            if len(args) < 1 or len(args) > 2:
                print "Usage: %s <queue> [<count>]" % COMMAND
                sys.exit(1)

            count = 1
            if len(args) == 2:
                try:
                    count = int(args[1])
                except ValueError:
                    print "Wrong count value '%s'. Using default %s" % (args[1], count)
            qkick(args[0], count)
        elif COMMAND == 'q-stat':
            if len(args) == 1:
                qstat(delay=int(args[0]))
            else:
                qstat()
        elif COMMAND == 'q-wrapper':
            if len(args) >= 3:
                qwrapper(args[0], args[1], worker_cmd=args[2:])
            else:
                print "Usage: %s <queue-in> <queue-out> [<cmd>]\n <cmd> could be sent trough STDIN" % (COMMAND)
                print sys.exit(1)
        elif COMMAND == 'q-wrapper-with-stats':
            if len(args) == 4:
                qwrapperwithstats(stats_queue_name, job_id, command)
            else:
                print "Usage: %s <statistics-queue> <job_id> <cmd>" % (COMMAND)
                print sys.exit(1)
        elif COMMAND == 'q-wrapper-batch':
            if len(args) >= 4:
                qwrapperbatch(args[0], args[1], worker_cmd=args[3:], batch_size=int(args[2]))
            else:
                print "Usage: %s <queue-in> <queue-out> <batch-size> <cmd>" % (COMMAND)
                print sys.exit(1)
        elif COMMAND == 'q-cleanup':
            if len(args) == 1:
                qcleanup(args[0])
            else:
                print "Usage: %s <queue>" % (COMMAND)
                print sys.exit(1)
        elif COMMAND == 'q-peek':
            if len(args) == 1:
                qpeekjob(args[0])
            else:
                print "Usage: %s <job_id>" % (COMMAND)
                print sys.exit(1)
        elif COMMAND == 'q-peek-ready':
            if len(args) == 1:
                qpeeknext(args[0], peek_type="ready")
            else:
                print "Usage: %s <queue>" % (COMMAND)
                print sys.exit(1)
        elif COMMAND == 'q-peek-delayed':
            if len(args) == 1:
                qpeeknext(args[0], peek_type="delayed")
            else:
                print "Usage: %s <queue>" % (COMMAND)
                print sys.exit(1)
        elif COMMAND == 'q-peek-buried':
            if len(args) == 1:
                qpeeknext(args[0], peek_type="buried")
            else:
                print "Usage: %s <queue>" % (COMMAND)
                print sys.exit(1)

        else:
            print "Unknown command '%s'" % COMMAND
    except __HOLE__:
        print "Keyboard Interrupt. Bye-bye"
dataset/ETHPy150Open chexov/queueit/beanstalkd/queueit/__init__.py/main