@@ -0,0 +1,2845 @@
+#!/usr/bin/env python3%0A%0Aimport inspect%0Afrom whalelinter.app import App%0A%0A%0Aclass Command:%0A    _callbacks = %7B%7D%0A%0A    @classmethod%0A    def register(cls, instance):%0A        def decorate(func, **kwargs):%0A%0A            if 'name' not in kwargs:%0A                name = func.__name__%0A            else:%0A                name = kwargs%5B'name'%5D%0A%0A            if (name not in cls._callbacks):%0A                cls._callbacks%5Bname%5D = %5B%5D%0A%0A            # if 'args' in kwargs and name in kwargs%5B'args'%5D:%0A%0A            cls._callbacks%5Bname%5D.append(%7B%0A                'instance': instance,%0A                'function': func,%0A                'kwargs'  : kwargs%0A            %7D)%0A%0A        return decorate%0A%0A    def react(self, name):%0A        if name in self._callbacks:%0A            for callback in self._callbacks%5Bname%5D:%0A                if (self == callback%5B'instance'%5D):%0A                    if callback%5B'kwargs'%5D:%0A                        callback%5B'function'%5D(callback%5B'instance'%5D, **callback%5B'kwargs'%5D)%0A                    else:%0A                        callback%5B'function'%5D(callback%5B'instance'%5D)%0A%0A%0Aclass PackageManager(Command):%0A%0A    def find_packages(self):%0A        lst = list(self.rest)%0A        for arg in self.args:%0A            lst.remove(arg)%0A%0A        subcommand = lst%5B0%5D%0A        lst.remove(lst%5B0%5D)%0A%0A        return (subcommand, lst)%0A%0A    def is_parameter_present(self, **kwargs):%0A        if 'parameter' in kwargs and 'args' in kwargs:%0A            if kwargs%5B'parameter'%5D not in kwargs%5B'args'%5D:%0A                App._collecter.throw(2010, self.line_number, keys=%7B%0A                    'parameter' : kwargs%5B'parameter'%5D,%0A                    'command'   : self.full_command%0A                %7D)%0A                return False%0A%0A        return True%0A%0A    def __init__(self, token, command, rest, line_number):%0A        %22%22%22%0A            RUN apt-get install -y name%0A%0A            RUN             : token%0A            apt-get         : command%0A            install -y name  : rest%0A%0A            install : subcommand%0A            -y      : args%0A            name     : packages%0A%0A        %22%22%22%0A        self.token          = token%0A        self.command        = command%0A        self.rest           = rest%0A        self.full_command   = self.command + ' ' + ' '.join(self.rest)%0A%0A        self.args           = %5Barg for arg in self.rest if (arg.startswith('-') or arg.startswith('--'))%5D%0A        self.line_number    = line_number%0A        self.methods        = %5B%5D%0A%0A        self.subcommand, self.packages = self.find_packages()%0A%0A        for method in inspect.getmembers(self, predicate=inspect.ismethod):%0A            if not method%5B0%5D.startswith('__') %5C%0A                and method%5B0%5D is not 'register' %5C%0A                and method%5B0%5D is not 'find_packages' %5C%0A                and method%5B0%5D is not 'is_parameter_present' %5C%0A                and method%5B0%5D is not 'react':%0A%0A                self.methods.append(method%5B0%5D)%0A

Create a Command class handling auto-dispatching for subcommands. Apt and others package-manager-classes should inherit from PackageManager class