@@ -0,0 +1,2288 @@
+# vim: fileencoding=utf-8 et sw=4 ts=4 tw=80:%0A%0A# python-quilt - A Python implementation of the quilt patch system%0A#%0A# Copyright (C) 2012  Bj%C3%B6rn Ricks %3Cbjoern.ricks@googlemail.com%3E%0A#%0A# This library is free software; you can redistribute it and/or%0A# modify it under the terms of the GNU Lesser General Public%0A# License as published by the Free Software Foundation; either%0A# version 2.1 of the License, or (at your option) any later version.%0A%0A# This library is distributed in the hope that it will be useful,%0A# but WITHOUT ANY WARRANTY; without even the implied warranty of%0A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A# Lesser General Public License for more details.%0A%0A# You should have received a copy of the GNU Lesser General Public%0A# License along with this library; if not, write to the Free Software%0A# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA%0A# 02110-1301 USA%0A%0Aimport os%0Aimport sys%0A%0Afrom optparse import OptionParser%0A%0Acommand_map = dict()%0A%0Adef register_command(name, command_class):%0A    command_map%5Bname%5D = command_class%0A%0Adef find_command(name):%0A    return command_map.get(name, None)%0A%0Adef list_commands():%0A    return sorted(command_map.items())%0A%0A%0Aclass CommandMetaClass(type):%0A%0A    def __new__(meta, name, bases, dict):%0A        cls = type.__new__(meta, name, bases, dict)%0A        if cls.name is not None:%0A            register_command(cls.name, cls)%0A        return cls%0A%0A%0Aclass Command(object):%0A%0A    __metaclass__ = CommandMetaClass%0A%0A    min_args = 0%0A    usage = %22%22%0A    patches_dir = %22patches%22%0A    pc_dir = %22.pc%22%0A    name = None%0A%0A    def parse(self, args):%0A        parser = OptionParser(usage=usage)%0A%0A        self.add_args(parser)%0A%0A        (options, pargs) = parser.parse_args(args)%0A%0A        if len(args) != self.min_args:%0A            parser.print_usage()%0A            sys.exit(1)%0A%0A        self.run(options, pargs)%0A%0A    def run(self, options, args):%0A        pass%0A%0A    def add_args(self, parser):%0A        pass%0A%0A    def get_patches_dir(self):%0A        patches_dir = os.environ.get(%22QUILT_PATCHES%22)%0A        if not patches_dir:%0A            patches_dir = self.patches_dir%0A        return patches_dir%0A%0A    def get_pc_dir(self):%0A        pc_dir = os.environ.get(%22QUILT_PC%22)%0A        if not pc_dir:%0A            pc_dir = self.pc_dir%0A        return pc_dir%0A

Introduce new quilt cli Command class