public static function autoload(Command $parent)
    {
        $reflector = new \ReflectionObject($parent);
        $dir = \dirname($reflector->getFileName()) . '/';

        /*
         * Commands to be autoloaded must located at specific directory.
         * If parent is Application, commands must be whthin App/Command/ directory.
         * If parent is another command named Foo or FooCommand, sub-commands must
         *      within App/Command/Foo/ directory, if App/Command/Foo/ directory
         *      not exists found in App/Command/Command/ directory.
         */
        if ($parent->isApplication()) {
            $subNamespace = 'Command';
        } else {
            $subNamespace = static::clearSuffix(
                $reflector->getShortName()
            );

            if (!\is_dir($dir . $subNamespace)) {
                $subNamespace = 'Command';
            }
        }

        $dir .= $subNamespace;
        if (!\is_dir($dir)) {
            return;
        }

        $classes = static::scanPhp($dir);
        $namespace = '\\' . $reflector->getNamespaceName() . '\\' . $subNamespace;

        foreach ($classes as $class) {
            $class = $namespace . '\\' . $class;

            $reflection = new \ReflectionClass($class);
            if ($reflection->isInstantiable()) {
                $parent->addCommand($class);
            }
        }
    }