Get current state of the CLI.

@return string[]
973414
protected function getCurrentState()
    {
        return [
            'application_name' => $this->config->get('application_name'),
            'application' => realpath($this->paths->getBasePath()),
            'configuration' => realpath($this->paths->getConfigurationPath()),
            'logs' => $this->paths->getLogsPath(),
        ];
    }
920429
protected function currentStatus()
    {
        if (! $masters = app(MasterSupervisorRepository::class)->all()) {
            return 'inactive';
        }

        return collect($masters)->contains(function ($master) {
            return $master->status === 'paused';
        }) ? 'paused' : 'running';
    }
256873
public function defaultCommands()
    {
        return [
            'server' => [
                'class' => ServerCommand::class,
            ],
            'server:start' => [
                'class' => ServerStartCommand::class,
            ],
            'server:stop' => [
                'class' => ServerStopCommand::class,
            ],
            'server:restart' => [
                'class' => ServerRestartCommand::class,
            ],
            'server:reload' => [
                'class' => ServerReloadCommand::class,
            ],
            'server:serve' => [
                'class' => ServerServeCommand::class,
            ],
            'shell' => [
                'class' => ShellCommand::class,
            ],
            'service:install' => [
                'class' => ServiceInstallCommand::class,
            ],
            'service:uninstall' => [
                'class' => ServiceUninstallCommand::class,
            ],
        ];
    }
91471
public function current() : array
    {
        return $this->result->fetch(\PDO::FETCH_ASSOC, \PDO::FETCH_ORI_ABS, $this->pointer);
    }
1027318
public function getModifiedFiles() {
		try {
			return $this->extractFromCommand ( 'git diff --name-status HEAD', function ($array) {
				$array = trim ( preg_replace ( '!\s+!', ' ', $array ) );
				return explode ( ' ', $array );
			} );
		} catch ( \Cz\Git\GitException $e ) {
			return [ ];
		}
	}
1012302
static public function getNotifiableStates()
    {
        $states = [];
        foreach (static::getConfig() as $state => $config) {
            if ($config[2]) {
                $states[] = $state;
            }
        }
        return $states;
    }
1359005
public function getAllCurrent()
    {
        $notifications = [];
        $container = $this->getContainer();

        foreach ($container as $namespace => $notification) {
            $notifications[$namespace] = $this->getCurrent($namespace);
        }

        return $notifications;
    }
760234
public function getStates()
    {
        $appID = App::getCurrentID();
        $complementID = self::getCurrentID();
        $states = $this->getStatesFromFile();

        if (isset($states[$appID][$complementID])) {
            return $this->states = $states[$appID][$complementID];
        }

        return $this->states = [];
    }
5216
protected function getCommands(): array
	{
		// Define core commands

		$commands =
		[
			'app.generate_key'    => GenerateKey::class,
			'app.generate_secret' => GenerateSecret::class,
		];

		if($this->container->has(Routes::class))
		{
			$commands = array_merge($commands,
			[
				'app.routes' => ListRoutes::class,
				'server'     => Server::class,
			]);
		}

		if($this->container->has(CacheManager::class))
		{
			$commands = array_merge($commands,
			[
				'cache.remove' => Remove::class,
				'cache.clear'  => Clear::class,
			]);
		}

		if($this->container->has(DatabaseConnectionManager::class))
		{
			$commands = array_merge($commands,
			[
				'migrate.create' => Create::class,
				'migrate.status' => Status::class,
				'migrate.up'     => Up::class,
				'migrate.down'   => Down::class,
				'migrate.reset'  => Reset::class,
			]);
		}

		// Add application commands

		$commands += $this->config->get('application.commands');

		// Add package commands

		foreach($this->packages as $package)
		{
			$commands += $package->getCommands();
		}

		// Return commands

		return $commands;
	}
967234
public static function getStateOfWorkers()
    {
        $offset = 0;

        $stat = [
            'idle' => 0,
            'busy' => 0,
            'alive' => 0,
            'shutdown' => 0,
            'preinit' => 0,
            'init' => 0,
            'reloading' => 0,
        ];
        $readed = 0;
        while (($buf = Daemon::$shm_wstate->read($readed, 1024)) !== false) {
            $buflen = mb_orig_strlen($buf);
            $readed += $buflen;
            for ($i = 0; $i < $buflen; ++$i) {
                $code = ord($buf[$i]);
                if ($code >= 100) {
                    // reloaded (shutdown)
                    $code -= 100;
                    if ($code !== Daemon::WSTATE_SHUTDOWN) {
                        ++$stat['alive'];
                        if (Daemon::$process instanceof Thread\Master) {
                            Daemon::$process->reloadWorker($offset + $i + 1);
                            ++$stat['reloading'];
                            continue;
                        }
                    }
                }
                if ($code === Daemon::WSTATE_IDLE) {
                    // idle
                    ++$stat['alive'];
                    ++$stat['idle'];
                } elseif ($code === Daemon::WSTATE_BUSY) {
                    // busy
                    ++$stat['alive'];
                    ++$stat['busy'];
                } elseif ($code === Daemon::WSTATE_SHUTDOWN) {
                    // shutdown
                    ++$stat['shutdown'];
                } elseif ($code === Daemon::WSTATE_PREINIT) {
                    // pre-init
                    ++$stat['alive'];
                    ++$stat['preinit'];
                    ++$stat['idle'];
                } elseif ($code === Daemon::WSTATE_INIT) { // init
                    ++$stat['alive'];
                    ++$stat['init'];
                    ++$stat['idle'];
                }
            }
        }
        return $stat;
    }
681762
protected function getComponents()
    {
        // Get user name
        $user = $this->localStorage->get('notifier.name');
        if (!$user) {
            $user = $this->command->ask('Who is deploying ?') ?: 'Someone';
            $this->localStorage->set('notifier.name', $user);
        }

        // Get what was deployed
        $repository = $this->credentials->getCurrentRepository();
        $connection = $this->connections->getCurrentConnectionKey();

        return [
            'user' => $user,
            'branch' => $repository->branch,
            'handle' => $connection->toHandle(),
            'host' => $connection->host,
            'repository' => $repository->getName(),
        ];
    }
1172349
protected function getCurrentPackageStates()
    {
        $savePackageStates = false;
        $loadedPackageStates = $this->loadPackageStates();
        if (
            empty($loadedPackageStates)
            || !isset($loadedPackageStates['version'])
            || $loadedPackageStates['version'] < self::PACKAGESTATE_FORMAT_VERSION
        ) {
            $loadedPackageStates = $this->scanAvailablePackages();
            $savePackageStates = true;
        }

        if ($savePackageStates) {
            $loadedPackageStates = $this->sortAndSavePackageStates($loadedPackageStates);
        }

        return $loadedPackageStates;
    }
1284071
public static function commands(){
       $results = [];
       foreach(static::$commands as $name => $cmd){
          $results[] = [
            'name'        => $name,
            'params'      => preg_replace('/:(\w+)/','[$1]',implode(' ',$cmd[0])),
            'description' => $cmd[2],
          ];
       }
       return $results;
    }
834792
private function getTranslatedStatus()
    {
        if ($this->status === null) {
            $this->status = [t('Active'), t('Inactive')];
        }

        return $this->status;
    }
140693
public function getStates()
    {
        $states = [];

        if (self::STATE_OFFLINE === $this->_state) {
            $states[] = self::STATE_OFFLINE;
        } elseif (self::STATE_HIDDEN === $this->_state) {
            $states[] = self::STATE_OFFLINE;
            $states[] = self::STATE_HIDDEN;
        } else {
            foreach (self::$STATES as $value) {
                if (0 !== ($this->_state & $value)) {
                    $states[] = $value;
                }
            }
        }

        return $states;
    }
1068505
public function getAll()
    {
        if (!$this->loadRepositories()) {
            return Repository::STATUS_NO_REPOSITORIES;
        }

        $modules = $this->getModulesFromRepository();

        // Is a higher version of an already installed package available?
        foreach ($modules as $key => $module) {
            $version = $this->packageService->getVersion($module->name);

            if (!$version) {
                // Not installed at all.
                unset($modules[$key]);
            } elseif (version_compare($version, $module->version, '<')) {
                // Older version installed.
                $modules[$key]->hasUpdate = true;
                $modules[$key]->versionInstalled = $version;
            } else {
                $modules[$key]->hasUpdate = false;
                $modules[$key]->versionInstalled = $version;
            }
        }

        return $modules;
    }
81343
protected function getStatusData() : array
    {
        $statusData = [
            'version' => self::VERSION,
            'starttime' => '',
            'uptime' => '',
            'active_worker' => [],
            'job_info' => [],
        ];

        $starttime = date('Y-m-d H:i:s', $this->startTime);
        $start = new \DateTime($starttime);
        $now = new \DateTime('now');
        $uptime = $start->diff($now)->format('%ad %Hh %Im %Ss');
        $statusData['starttime'] = $starttime;
        $statusData['uptime'] = $uptime;

        foreach (array_keys($this->processes) as $poolName) {
            if (!isset($statusData['active_worker'][$poolName])) {
                $statusData['active_worker'][$poolName] = 0;
            }
            /** @var Process $process */
            foreach ($this->processes[$poolName] as $process) {
                $processIsRunning = $process->isRunning();
                if ($processIsRunning === true) {
                    $statusData['active_worker'][$poolName]++;
                }
            }
        }
        $statusData['job_info']['job_requests_total'] = $this->totalJobRequests;
        $statusData['job_info']['queue_length'] = $this->jobsInQueue;
        $statusData['job_info']['worker_stats'] = $this->workerStats;
        return $statusData;
    }