#!/usr/bin/python3
# pylint: disable=missing-module-docstring,invalid-name
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Novell, Inc.
#   This library is free software; you can redistribute it and/or modify
# it only under the terms of version 2.1 of the GNU Lesser General Public
# License as published by the Free Software Foundation.
#
#   This library 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 Lesser General Public License for more
# details.
#
#   You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from __future__ import print_function

# pylint: disable-next=unused-import
import sys
from optparse import OptionParser
from spacewalk.susemanager import mgr_clean_old_patchnames


def main():
    parser = OptionParser(
        version="%prog 0.1",
        description="Remove patches with old patchnames from the given channels",
    )

    parser.add_option(
        "-a", "--all", action="store_true", dest="all", help="iterate over all channels"
    )
    parser.add_option(
        "-c", "--channel", action="store", dest="channel", help="channel name"
    )
    parser.add_option("-d", "--debug", dest="debug", default=0, help="debugging")

    # pylint: disable-next=unused-variable
    (options, args) = parser.parse_args()

    cleaner = mgr_clean_old_patchnames.Cleaner(
        all=options.all, channel=options.channel, debug=options.debug
    )

    cleaner.run()


if __name__ == "__main__":
    try:
        main()
    except IOError as e:
        # pylint: disable-next=consider-using-f-string
        print("ERROR: %s" % e)
