Determine the command type of the node.

@return void
348166
protected function determineCommand()
    {
        if (mb_strlen($this->source) === 0) {
            $this->isInterrupted = true;

            return;
        }

        $this->command = mb_substr($this->source, 0, 1);
    }
343238
protected function handleControlStructure($node) {
    $this->handleParens($node);
    $colons = $node->children(Filter::isTokenType(':'));
    foreach ($colons as $colon) {
      $this->removeSpaceBefore($colon);
    }
    if ($colons->isNotEmpty()) {
      $this->newlineBefore($node->lastChild()->previous());
    }
  }
190410
def _get_controller_type(self):
        """"""

        if self.node_type == self.NODE_CONTROLLER_ROOT and self.name in self.CONTROLLERS:
            return self.name
        elif self.parent:
            return self.parent.controller_type
        else:
            return None
542330
protected function detectRoot()
    {
        if ($this->menu->root == -1 && $this->menu->rootLevel)
        {
            $parents = $this->Eresus->sections->parents($this->ui->id);
            $level = count($parents);
            if ($level == $this->menu->rootLevel)
            {
                $this->menu->root = -1;
            }
            elseif ($level > $this->menu->rootLevel)
            {
                $this->menu->root = $parents[$this->menu->rootLevel];
            }
            else
            {
                $this->menu->root = -2;
            }
        }
    }
1324358
protected function generateNodeTypeDefinitions()
    {
        $code = '';
        /** @var NodeType $nodeType */
        foreach ($this->nodeTypeManager->getNodeTypes(false) as $nodeType) {
            $code .= $this->generateFusionForNodeType($nodeType);
        }
        return $code;
    }
254571
public function commands()
    {
        $shellList = $this->getShellList();
        $flatten = Hash::flatten($shellList);
        $duplicates = array_intersect($flatten, array_unique(array_diff_key($flatten, array_unique($flatten))));
        $duplicates = Hash::expand($duplicates);

        $options = [];
        foreach ($shellList as $type => $commands) {
            foreach ($commands as $shell) {
                $prefix = '';
                if (!in_array(strtolower($type), ['app', 'core']) &&
                    isset($duplicates[$type]) &&
                    in_array($shell, $duplicates[$type])
                ) {
                    $prefix = $type . '.';
                }

                $options[] = $prefix . $shell;
            }
        }

        return $options;
    }
698476
protected function cmdExport() /*: void*/
    {
        /**
         * @see simplecomplex_locale_text_cli()
         */
        $container = Dependency::container();
        // Validate input. ---------------------------------------------
        $language = '';
        if (empty($this->command->arguments['language'])) {
            $this->command->inputErrors[] = !isset($this->command->arguments['language']) ?
                'Missing \'language\' argument.' : 'Empty \'language\' argument.';
        } else {
            $language = $this->command->arguments['language'];
            if (!LocaleCode::validate($language)) {
                $this->command->inputErrors[] = 'Invalid \'language\' argument.';
            }
        }
        $target_file = '';
        if (empty($this->command->arguments['target-file'])) {
            $this->command->inputErrors[] = !isset($this->command->arguments['target-file']) ?
                'Missing \'target-file\' argument.' : 'Empty \'target-file\' argument.';
        } else {
            $target_file = $this->command->arguments['target-file'];
        }

        $from_sources = !empty($this->command->options['from-sources']);
        $format = !empty($this->command->options['format']) ? $this->command->options['format'] : 'JSON';
        $unescaped = !empty($this->command->options['unescaped']);
        $pretty = !empty($this->command->options['pretty']);

        // Pre-confirmation --yes/-y ignored for this command.
        if ($this->environment->riskyCommandRequireConfirm && $this->command->preConfirmed) {
            $this->command->inputErrors[] = 'Pre-confirmation \'yes\'/-y option not supported for this command,'
                . "\n" . 'unless env var PHP_LIB_SIMPLECOMPLEX_UTILS_CLI_SKIP_CONFIRM'
                . "\n" . 'or .risky_command_skip_confirm file in document root.';
        }
        if ($this->command->inputErrors) {
            foreach ($this->command->inputErrors as $msg) {
                $this->environment->echoMessage(
                    $this->environment->format($msg, 'hangingIndent'),
                    'notice'
                );
            }
            // This command's help text.
            $this->environment->echoMessage("\n" . $this->command);
            exit;
        }
        // Check if the command is doable.------------------------------
        if ($container->has('config')) {
            /** @var \SimpleComplex\Config\IniSectionedConfig $config */
            $config = $container->get('config');
        } else {
            $config_class = static::CLASS_CONFIG;
            /** @var \SimpleComplex\Config\IniSectionedConfig $config */
            $config = new $config_class('global');
        }
        $locale_text_paths = $config->get('lib_simplecomplex_locale', 'localeTextPaths');
        if (!$locale_text_paths) {
            $this->environment->echoMessage(
                'Global config misses item section[lib_simplecomplex_locale] key[localeTextPaths].',
                'warning'
            );
            exit;
        }
        if (!is_array($locale_text_paths)) {
            $this->environment->echoMessage(
                'Global config item section[lib_simplecomplex_locale] key[localeTextPaths] is not array.',
                'error'
            );
            exit;
        }
        // localeTextPaths are relative to vendor dir, unless absolute.
        $vendor_dir = Utils::getInstance()->vendorDir();
        foreach ($locale_text_paths as &$path) {
            if ($path{0} !== '/' && strpos($path, $vendor_dir . '/') !== 0) {
                $path = $vendor_dir . '/' . $path;
            }
        }
        unset($path);
        // Do it.
        $locale_text_class = static::CLASS_LOCALE_TEXT;
        /** @var LocaleText $locale_text */
        $locale_text = new $locale_text_class($language, $locale_text_paths);
        // Display command and the arg values used.---------------------
        if ($this->environment->riskyCommandRequireConfirm || !$this->command->preConfirmed) {
            $this->environment->echoMessage(
                $this->environment->format(
                    $this->environment->format($this->command->name, 'emphasize')
                    . "\n" . 'language: ' . $language
                    . "\n" . 'target-file: ' . $target_file
                    . (!$this->command->options ? '' : ("\n--" . join(' --', array_keys($this->command->options)))),
                    'hangingIndent'
                )
            );
        }
        // Request confirmation, ignore --yes/-y pre-confirmation option;
        // unless .risky_command_skip_confirm file placed in document root.
        if ($this->environment->riskyCommandRequireConfirm) {
            if (!$this->environment->confirm(
                'Export that locale-text language from ' . (!$from_sources ? 'cache' : 'sources')
                . ' - will overwrite the target file (if exists)?'
                . "\n" . 'Type \'yes\' to continue:',
                ['yes'],
                '',
                'Aborted exporting locale-text language.'
            )) {
                exit;
            }
        } elseif (!$this->command->preConfirmed && !$this->environment->confirm(
                'Export that locale-text language from ' . (!$from_sources ? 'cache' : 'sources')
                . ' - will overwrite the target file (if exists)?'
                . "\n" . 'Type \'yes\' or \'y\' to continue:',
                ['yes', 'y'],
                '',
                'Aborted exporting locale-text language.'
            )) {
            exit;
        }
        // Do it.
        if (!$locale_text->export(
            $target_file,
            [
                'fromSources' => $from_sources,
                'format' => strtoupper($format),
                'unescaped' => $unescaped,
                'pretty' => $pretty,
            ]
        )) {
            $this->environment->echoMessage('Failed to export locale-text language[' . $language . '].', 'error');
        } elseif (!$this->command->silent) {
            $this->environment->echoMessage(
                'Exported locale-text language[' . $language . '] from ' . (!$from_sources ? 'cache' : 'sources')
                . ' to target file[' . $target_file . '].',
                'success'
            );
        }
        exit;
    }
102969
public function blockMsgCommand(): int
    {
        if (!$this->output->supportColor()) {
            $this->write('Current terminal is not support output color text.');

            return 0;
        }

        $this->write('block message:');

        foreach (Show::getBlockMethods() as $type) {
            $this->output->$type("$type style message text");
        }

        return 0;
    }
1174743
public function cmdDeleteCurrency()
    {
        $id = $this->getParam(0);
        $all = $this->getParam('all');

        if (empty($id) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $result = false;

        if (!empty($id)) {
            $result = $this->currency->delete($id);
        } else if (!empty($all)) {
            $deleted = $count = 0;
            foreach ($this->currency->getList(array('in_database' => true)) as $currency) {
                $count++;
                $deleted += (int) $this->currency->delete($currency['code']);
            }
            $result = ($count == $deleted);
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
263138
private function determineOperatingSystem()
	{
		$this->os = strtoupper(substr(PHP_OS, 0, 3));

		if ($this->os === 'WIN')
		{
			$this->fileExtension = '.exe';
		}
	}
1199900
public function show_synopsis_if_composite_command() {
		$r = $this->find_command_to_run( $this->arguments );
		if ( is_array( $r ) ) {
			list( $command ) = $r;

			if ( $command->can_have_subcommands() ) {
				$command->show_usage();
				exit;
			}
		}
	}
932610
public function run(): int
	{
		$this->handleGlobalOptions();

		if(($command = $this->input->getArgument(1)) === null)
		{
			return $this->displayReactorInfoAndCommandList();
		}

		if($this->commandExists($command) === false)
		{
			return $this->unknownCommand($command);
		}

		if($this->input->getArgument('help', false) !== false)
		{
			return $this->displayCommandHelp($command);
		}

		return $this->dispatch($command);
	}
1106644
public function showMappingCommand(): void
    {
        $nodeTypeMappingCollection = $this->nodeTypeMappingBuilder->buildMappingInformation($this->nodeIndexer->getIndex());
        foreach ($nodeTypeMappingCollection as $mapping) {
            /** @var Mapping $mapping */
            $this->output(Yaml::dump($mapping->asArray(), 5, 2));
            $this->outputLine();
        }
        $this->outputLine('------------');

        $mappingErrors = $this->nodeTypeMappingBuilder->getLastMappingErrors();
        if ($mappingErrors->hasErrors()) {
            $this->outputLine('<b>Mapping Errors</b>');
            foreach ($mappingErrors->getFlattenedErrors() as $errors) {
                foreach ($errors as $error) {
                    $this->outputLine($error);
                }
            }
        }

        if ($mappingErrors->hasWarnings()) {
            $this->outputLine('<b>Mapping Warnings</b>');
            foreach ($mappingErrors->getFlattenedWarnings() as $warnings) {
                foreach ($warnings as $warning) {
                    $this->outputLine($warning);
                }
            }
        }
    }
1142074
private function nodeJsCommand()
    {

        // todo check nodejs exists in windows os
        return true;
        $found = false;
        foreach (['node', 'nodejs'] as $command) {
            $this->process->setCommandLine('which ' . $command);
            $this->process->setTimeout(null);
            $this->process->run();

            if ($this->process->isSuccessful()) {
                $found = true;
                break;
            }
        }

        if (!$found) {
            $this->console->error('node.js was not found');
            $this->errors =  true;
        }
    }
880081
protected function determineViewType()
    {
        $filename = Core::i()->request_uri;
        $extension = HTTPUtilities::getFileExtension($filename);
        if (PHP_SAPI === 'cli' || PHP_SAPI === 'cli-server') {
            // Extension is irrelevant, use the cli renderer
            $this->setViewType('c l i');
            $url_array[] = $filename;
        } elseif (!is_null($extension)) {
            $this->setViewType($extension);
        }
        Core::i()->log->debug('View Type: ' . $this->view_type);
    }
800917
protected function configure()
	{
		// the short description shown while running "php bin/console list"
		if( $this->docs->getIs("description") )
		{
			$this->setDescription($this->docs["description"]);
		}

		// the full command description shown when running the command with
		// the "--help" option
		if( $this->docs->getIs("help") )
		{
			$this->setHelp($this->docs["help"]);
		}
	}
658570
private function inspectApplication()
	{
		$this->commands   = [];
		$this->namespaces = [];

		$all = $this->application->getAllCommands($this->namespace ? $this->application->findNamespace($this->namespace) : '');

		foreach ($this->sortCommands($all) as $namespace => $commands)
		{
			$names = [];

			/** @var AbstractCommand $command */
			foreach ($commands as $name => $command)
			{
				if (!$command->getName() || (!$this->showHidden && $command->isHidden()))
				{
					continue;
				}

				if ($command->getName() === $name)
				{
					$this->commands[$name] = $command;
				}
				else
				{
					$this->aliases[$name] = $command;
				}

				$names[] = $name;
			}

			$this->namespaces[$namespace] = ['id' => $namespace, 'commands' => $names];
		}
	}