#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- python-mode -*-
from __future__ import absolute_import, division, print_function, unicode_literals

import os

__copyright__ = """
Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

This program 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, see http://www.gnu.org/licenses/.
"""

if __name__ == '__main__':
    if os.environ.get('COVERAGE_PROCESS_START'):
        import coverage
        import sys

        if len(sys.argv) < 2 or sys.argv[1].startswith('-'):
            context = 'stg'
        else:
            context = 'stg-' + sys.argv[1]

        cov = coverage.process_startup()
        cov.switch_context(context)

    from stgit.main import main

    main()
