protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (null === $this->em) {
            $this->em = $this->getContainer()->get('doctrine.orm.entity_manager');
        }

        $groupName = $input->getArgument('group');
        $roleNames = $input->getOption('role');
        $group = new Group($groupName);

        if (!empty($roleNames)) {
            // Roles were provided, so attach them to the group
            $roleNames = explode(',', strtoupper($roleNames));
            foreach ($roleNames as $roleName) {
                if ('ROLE_' != substr($roleName, 0, 5)) {
                    $roleName = 'ROLE_' . $roleName;
                }
                /* @var Role $role */
                $role = $this->em->getRepository('KunstmaanAdminBundle:Role')->findOneBy(array('role' => $roleName));
                $group->addRole($role);
            }
        }
        $this->em->persist($group);
        $this->em->flush();

        $output->writeln(sprintf('Created group <comment>%s</comment>', $groupName));
    }