#!/usr/bin/env python

# This file belongs to Happy Camel.
#
# Copyright (C) 2006-2008 Pieter Edelman
# (p _dot_ edelman AT gmx _dot_ net)
#
# Happy Camel is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; version 2 only.
#
# Happy Camel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

""" The main Happy Camel script. It does some basic checks, and then starts up
    the command line interface. """
    
# Import standard modules
import sys
# Import Happy Camel modules
from HappyCamel import cli, logger

# The constants
PROGRAM_NAME     = "Happy Camel"
PROGRAM_VERSION  = "1-beta3"
# The minimally required Python version. Should be three numbers
REQUIRED_VERSION = (2, 4, 0)

if (__name__ == "__main__"):
  # Create a logger
  logger = logger.Logger()
  logger.setFormat("%(message)s")
  
  # Check the Python version        
  for index in range(len(REQUIRED_VERSION)):
    if (sys.version_info[index] < REQUIRED_VERSION[index]):
      logger.error("You need at least Python version %d.%d.%d (Found %d.%d.%d)"
                    % (REQUIRED_VERSION + sys.version_info[:3]))
      sys.exit(1)

  # Create a command-line interface
  cli = cli.CLI(PROGRAM_NAME, PROGRAM_VERSION, logger)
  
  # Run camel run
  cli.run()
