Creates an Help object from a FQDN

@param string $fqdn
@param string $subCommand
@return Help
482723
public static function fromFQDN($fqdn, $subCommand = null)
    {
        if (function_exists($fqdn)) {
            return self::fromFunction($fqdn);
        }
        if (class_exists($fqdn) && is_subclass_of($fqdn, 'ConsoleKit\Command')) {
            return self::fromCommandClass($fqdn, $subCommand);
        }
        throw new ConsoleException("'$fqdn' is not a valid ConsoleKit FQDN");
    }
659652
public function build(string $fqcn)
    {
        try {
            return $this->doBuild($fqcn);
        } catch (\Throwable $exception) {
            throw new MockNotCreatedException(
                sprintf(
                    'Cannot create mock object for FQCN "%s": %s',
                    $fqcn,
                    $exception->getMessage()
                )
            );
        }
    }
1179775
protected function doBuild(string $fqcn): MockObject
    {
        return $this->generator->getMock(
            $fqcn,
            $methods = [],
            $arguments = [],
            $mockClassName = '',
            $callOriginalConstructor = false
        );
    }
1129
public function get_subdef($subdef_type, $subdef_name)
    {
        $type = strtolower($subdef_type);
        $name = strtolower($subdef_name);

        $group = $this->getSubdefGroup(strtolower($subdef_type));

        if (!$group) {
            throw new Exception_Databox_SubdefNotFound(sprintf('Databox subdef name `%s` of type `%s` not found', $name, $type));
        }

        try {
            return $group->getSubdef($name);
        } catch (RuntimeException $exception) {
            throw new Exception_Databox_SubdefNotFound(sprintf('Databox subdef name `%s` of type `%s` not found', $name, $type), $exception);
        }
    }
71824
function getSubCommands(context, command) {
  var commands = cli.getMapping(context).requisition.system.commands;
  var subcommands = commands.getAll().filter(function(subcommand) {
    return subcommand.name.indexOf(command.name) === 0 &&
           subcommand.name !== command.name &&
           !subcommand.hidden;
  });

  subcommands.sort(function(c1, c2) {
    return c1.name.localeCompare(c2.name);
  });

  subcommands = subcommands.map(function(subcommand) {
    return subcommand.toJson();
  });

  return subcommands;
}
537662
private BitFieldArgs addSubCommand(SubCommand subCommand) {

        LettuceAssert.notNull(subCommand, "SubCommand must not be null");
        commands.add(subCommand);
        return this;
    }
420573
def set_cmdln_info(self, cmdln, subcmd):
        
        self.cmdln = cmdln
        self.subcmd = subcmd
331943
public function get(string $fqcn): ProxyInterface
    {
        $mock = $this->mockingStrategy->build($fqcn);
        $mockFQCN = \get_class($this->mockingStrategy->get($mock));
        $mockClass = new \ReflectionClass($mockFQCN);

        $proxyCode = ClassTemplate::generate($mockClass);
        $proxyFQCN = eval($proxyCode);

        return $this->getInstance($proxyFQCN)
            ->__moka_setMock($mock)
            ->__moka_setMockingStrategy($this->mockingStrategy);
    }
76486
public function help()
    {
        $tf = new TableFormatter($this->colors);
        $text = '';

        $hascommands = (count($this->setup) > 1);
        foreach ($this->setup as $command => $config) {
            $hasopts = (bool)$this->setup[$command]['opts'];
            $hasargs = (bool)$this->setup[$command]['args'];

            // usage or command syntax line
            if (!$command) {
                $text .= $this->colors->wrap('USAGE:', Colors::C_BROWN);
                $text .= "\n";
                $text .= '   ' . $this->bin;
                $mv = 2;
            } else {
                $text .= "\n";
                $text .= $this->colors->wrap('   ' . $command, Colors::C_PURPLE);
                $mv = 4;
            }

            if ($hasopts) {
                $text .= ' ' . $this->colors->wrap('<OPTIONS>', Colors::C_GREEN);
            }

            if (!$command && $hascommands) {
                $text .= ' ' . $this->colors->wrap('<COMMAND> ...', Colors::C_PURPLE);
            }

            foreach ($this->setup[$command]['args'] as $arg) {
                $out = $this->colors->wrap('<' . $arg['name'] . '>', Colors::C_CYAN);

                if (!$arg['required']) {
                    $out = '[' . $out . ']';
                }
                $text .= ' ' . $out;
            }
            $text .= "\n";

            // usage or command intro
            if ($this->setup[$command]['help']) {
                $text .= "\n";
                $text .= $tf->format(
                    array($mv, '*'),
                    array('', $this->setup[$command]['help'] . "\n")
                );
            }

            // option description
            if ($hasopts) {
                if (!$command) {
                    $text .= "\n";
                    $text .= $this->colors->wrap('OPTIONS:', Colors::C_BROWN);
                }
                $text .= "\n";
                foreach ($this->setup[$command]['opts'] as $long => $opt) {

                    $name = '';
                    if ($opt['short']) {
                        $name .= '-' . $opt['short'];
                        if ($opt['needsarg']) {
                            $name .= ' <' . $opt['needsarg'] . '>';
                        }
                        $name .= ', ';
                    }
                    $name .= "--$long";
                    if ($opt['needsarg']) {
                        $name .= ' <' . $opt['needsarg'] . '>';
                    }

                    $text .= $tf->format(
                        array($mv, '30%', '*'),
                        array('', $name, $opt['help']),
                        array('', 'green', '')
                    );
                    $text .= "\n";
                }
            }

            // argument description
            if ($hasargs) {
                if (!$command) {
                    $text .= "\n";
                    $text .= $this->colors->wrap('ARGUMENTS:', Colors::C_BROWN);
                }
                $text .= "\n";
                foreach ($this->setup[$command]['args'] as $arg) {
                    $name = '<' . $arg['name'] . '>';

                    $text .= $tf->format(
                        array($mv, '30%', '*'),
                        array('', $name, $arg['help']),
                        array('', 'cyan', '')
                    );
                }
            }

            // head line and intro for following command documentation
            if (!$command && $hascommands) {
                $text .= "\n";
                $text .= $this->colors->wrap('COMMANDS:', Colors::C_BROWN);
                $text .= "\n";
                $text .= $tf->format(
                    array($mv, '*'),
                    array('', 'This tool accepts a command as first parameter as outlined below:')
                );
                $text .= "\n";
            }
        }

        return $text;
    }
636867
public static function fqcnToBlockPrefix(string $fqcn): ?string
    {
        // Non-greedy ("+?") to match "type" suffix, if present
        if (preg_match('~([^\\\\]+?)(type)?$~i', $fqcn, $matches)) {
            return mb_strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], ['\\1_\\2', '\\1_\\2'], $matches[1]));
        }

        return null;
    }
547018
protected function createCommand($commandName, array $commandDca)
    {

        $command = $this->createCommandInstance($commandName, $commandDca);
        $command->setName($commandName);

        $parameters = $command->getParameters();

        if (isset($commandDca['href'])) {
            \parse_str($commandDca['href'], $queryParameters);
            foreach ($queryParameters as $name => $value) {
                $parameters[$name] = $value;
            }
            unset($commandDca['href']);
        }

        if (isset($commandDca['parameters'])) {
            foreach ($commandDca['parameters'] as $name => $value) {
                $parameters[$name] = $value;
            }
            unset($commandDca['parameters']);
        }

        if (isset($commandDca['label'])) {
            $lang = $commandDca['label'];

            if (\is_array($lang)) {
                $label       = \reset($lang);
                $description = \next($lang);

                $command->setDescription($description);
            } else {
                $label = $lang;
            }

            $command->setLabel($label);

            unset($commandDca['label']);
        }

        if (isset($commandDca['description'])) {
            $command->setDescription($commandDca['description']);

            unset($commandDca['description']);
        }

        // Callback is transformed into event in parseCallbacks().
        unset($commandDca['button_callback']);

        if (\count($commandDca)) {
            $extra = $command->getExtra();

            foreach ($commandDca as $name => $value) {
                $extra[$name] = $value;
            }
        }

        return $command;
    }
1114019
private function createFromCommand()
    {
        $command = MainCommand::getInstance($this->repository)->status(true);
        $lines = $this->repository->getCaller()->execute($command)->getOutputLines(true);
        $this->parseOutputLines($lines);
    }
1196611
def create(cls, fqdn, duration, owner, admin, tech, bill, nameserver,
               extra_parameter, background):
        """"""
        fqdn = fqdn.lower()
        if not background and not cls.intty():
            background = True

        result = cls.call('domain.available', [fqdn])
        while result[fqdn] == 'pending':
            time.sleep(1)
            result = cls.call('domain.available', [fqdn])

        if result[fqdn] == 'unavailable':
            raise DomainNotAvailable('%s is not available' % fqdn)

        # retrieve handle of user and save it to configuration
        user_handle = cls.call('contact.info')['handle']
        cls.configure(True, 'api.handle', user_handle)

        owner_ = owner or user_handle
        admin_ = admin or user_handle
        tech_ = tech or user_handle
        bill_ = bill or user_handle

        domain_params = {
            'duration': duration,
            'owner': owner_,
            'admin': admin_,
            'tech': tech_,
            'bill': bill_,
        }

        if nameserver:
            domain_params['nameservers'] = nameserver

        if extra_parameter:
            domain_params['extra'] = {}
            for extra in extra_parameter:
                domain_params['extra'][extra[0]] = extra[1]

        result = cls.call('domain.create', fqdn, domain_params)
        if background:
            return result

        # interactive mode, run a progress bar
        cls.echo('Creating your domain.')
        cls.display_progress(result)
        cls.echo('Your domain %s has been created.' % fqdn)
684009
public function getSingularNamespacedName(string $entityFqn, array $subDirectories): string
    {
        $singular = \ucfirst(MappingHelper::getSingularForFqn($entityFqn));

        return $this->getNamespacedName($singular, $subDirectories);
    }
5165
def _get_subcommand(name):
    # type: (str) -> config.RcliEntryPoint
    
    _LOGGER.debug('Accessing subcommand "%s".', name)
    if name not in settings.subcommands:
        raise ValueError(
            '"{subcommand}" is not a {command} command. \'{command} help -a\' '
            'lists all available subcommands.'.format(
                command=settings.command, subcommand=name)
        )
    return settings.subcommands[name]
1081306
public function helpCommand()
    {
        $args = $this->cliHandler->getArgs();
        if (isset($args[2]) && $args[2] !== 'help' && $args[2][0] !== '-') {
            $actionName = $args[2];
        } elseif (isset($args[3]) && $args[2] === 'help' && $args[3][0] !== '-') {
            $actionName = $args[3];
        } else {
            $actionName = '';
        }

        foreach (get_class_methods($this) as $method) {
            if (!preg_match('#^([a-z].*)Command$#', $method, $match)) {
                continue;
            }

            if ($actionName && $match[1] !== $actionName) {
                continue;
            }

            $rm = new \ReflectionMethod($this, $method);
            if (!$rm->isPublic()) {
                continue;
            }

            $lines = [];
            foreach (preg_split('#[\r\n]+#', $rm->getDocComment()) as $line) {
                $lines[] = trim($line, "\t /*\r\n");
            }

            $description = '';
            foreach ($lines as $line) {
                if (!$line) {
                    continue;
                }

                if ($line[0] !== '@') {
                    $description = $line;
                }
                break;
            }

            $command = $this->console->colorize(str_pad(basename($method, 'Command'), 10), Console::FC_YELLOW) . ' ' . $description;
            $this->console->writeLn($command);

            $defaultValues = [];
            foreach ($rm->getParameters() as $parameter) {
                if ($parameter->isDefaultValueAvailable()) {
                    $defaultValues[$parameter->getName()] = $parameter->getDefaultValue();
                }
            }

            $params = [];
            foreach ($lines as $line) {
                if (strpos($line, '@param') === false) {
                    continue;
                }

                $parts = preg_split('#\s+#', $line, 4);
                if (count($parts) < 3 || $parts[0] !== '@param') {
                    continue;
                }
                $name = substr($parts[2], 1);
                $type = $parts[1];

                if (isset($defaultValues[$name])) {
                    if ($type === 'bool' || $type === 'boolean') {
                        $defaultValues[$name] = $defaultValues[$name] ? 'YES' : 'NO';
                    } elseif ($type === 'int' || $type === 'integer') {
                        $defaultValues[$name] = (int)$defaultValues[$name];
                    } elseif ($type === 'float' || $type === 'double') {
                        $defaultValues[$name] = (float)$defaultValues[$name];
                    } elseif ($type === 'string') {
                        $defaultValues[$name] = json_encode($defaultValues[$name], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
                    } elseif ($type === 'array') {
                        $defaultValues[$name] = json_encode($defaultValues[$name], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
                    }
                }

                $params[$name] = isset($parts[3]) ? trim($parts[3]) : '';
            }

            if ($params) {
                $shortNames = [];
                foreach ($params as $name => $description) {
                    $short = $name[0];
                    if (isset($shortNames[$short])) {
                        $shortNames[$short] = false;
                    } else {
                        $shortNames[$short] = $name;
                    }
                }
                $shortNames = array_flip(array_filter($shortNames));

                $width = 1;
                foreach ($params as $name => $description) {
                    $width = max($width, strlen($name) + 2 + (isset($shortNames[$name]) ? 4 : 0));
                }
                $this->console->writeLn('  Options:');

                foreach ($params as $name => $value) {
                    $option = '--' . $name;
                    if (isset($shortNames[$name])) {
                        $option .= ', -' . $shortNames[$name];
                    }
                    $this->console->writeLn(['    :option :value :default',
                        'option' => $this->console->colorize($option, Console::FC_CYAN, $width),
                        'value' => $value ? "  $value" : '',
                        'default' => isset($defaultValues[$name]) ? " (default: $defaultValues[$name])" : '']);
                }
            }
        }
    }
478
public function find_subcommand( &$args ) {
		$name = array_shift( $args );

		$subcommands = $this->get_subcommands();

		if ( ! isset( $subcommands[ $name ] ) ) {
			$aliases = self::get_aliases( $subcommands );

			if ( isset( $aliases[ $name ] ) ) {
				$name = $aliases[ $name ];
			}
		}

		if ( ! isset( $subcommands[ $name ] ) ) {
			return false;
		}

		return $subcommands[ $name ];
	}