#!/usr/bin/env python
#
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""Command line tool for interacting with Google TaskQueue API."""

__version__ = '0.0.1'


import logging

from gtaskqueue import task_cmds
from gtaskqueue import taskqueue_cmds

from google.apputils import appcommands
import gflags as flags

LOG_LEVELS = [logging.DEBUG,
              logging.INFO,
              logging.WARNING,
              logging.CRITICAL]
LOG_LEVEL_NAMES = map(logging.getLevelName, LOG_LEVELS)
FLAGS = flags.FLAGS

flags.DEFINE_enum(
        'log_level',
        logging.getLevelName(logging.WARNING),
        LOG_LEVEL_NAMES,
        'Logging output level.')


def main(unused_argv):
    log_level_map = dict(
        [(logging.getLevelName(level), level) for level in LOG_LEVELS])
    logging.getLogger().setLevel(log_level_map[FLAGS.log_level])
    taskqueue_cmds.add_commands()
    task_cmds.add_commands()

if __name__ == '__main__':
    appcommands.Run()
