<commit_before><?php
/**
 * Actions on multiple sites
 *
 */
use Terminus\Utils;
use Terminus\Organization;
use Terminus\Products;
use Terminus\Session;
use Terminus\SitesCache;
use Terminus\Site;
use Terminus\SiteFactory;
use Terminus\Auth;
use Terminus\Helpers\Input;
use Terminus\User;
use Symfony\Component\Finder\SplFileInfo;
use Terminus\Loggers\Regular as Logger;
use Terminus\Workflow;

class Sites_Command extends Terminus_Command {
  public $sitesCache;

  /**
   * Show a list of your sites on Pantheon
   * @package Terminus
   * @version 2.0
   */
  public function __construct() {
    parent::__construct();
    Auth::loggedIn();

    $this->sitesCache = new SitesCache();
  }

  /**
   * Show all sites user has access to
   * Note: because of the size of this call, it is cached
   *   and also is the basis for loading individual sites by name
   *
   * @subcommand list
   * @alias show
   */
  public function index($args, $assoc_args) {
    // Always fetch a fresh list of sites
    $this->sitesCache->rebuild();
    $cached_sites = $this->sitesCache->all();

    if (count($cached_sites) == 0) {
      Terminus::log("You have no sites.");
      exit(0);
    }

    $rows = array_map(function($cached_site) {
      return array(
        'name' => $cached_site['name'],
        'id' => $cached_site['id'],
        'service_level' => $cached_site['service_level'],
        'framework' => $cached_site['framework'],
        'memberships' => array_map(function($membership) {
          return $membership['name'];
        }, $cached_site['memberships'])
      );
    }, $cached_sites);

    $this->handleDisplay($rows);
    return $rows;
  }


  /**
   * Create a new site
   *
   * ## OPTIONS
   *
   * [--site=<site>]
   * : Name of the site to create (machine-readable)
   *
   * [--name=<name>]
   * : (deprecated) use --site instead
   *
   * [--label=<label>]
   * : Label for the site
   *
   * [--product=<productid>]
   * : Specify the upstream product to use
   *
   * [--import=<url>]
   * : A url to import a valid archive
   *
   * [--org=<org>]
   * : UUID of organization into which to add this site
   *
   */
  public function create($args, $assoc_args) {
    $options = array();
    $options['label'] = Input::string($assoc_args, 'label', "Human readable label for the site");<commit_msg>Improve  output to be proper list of hashes<commit_after><?php
/**
 * Actions on multiple sites
 *
 */
use Terminus\Utils;
use Terminus\Organization;
use Terminus\Products;
use Terminus\Session;
use Terminus\SitesCache;
use Terminus\Site;
use Terminus\SiteFactory;
use Terminus\Auth;
use Terminus\Helpers\Input;
use Terminus\User;
use Symfony\Component\Finder\SplFileInfo;
use Terminus\Loggers\Regular as Logger;
use Terminus\Workflow;

class Sites_Command extends Terminus_Command {
  public $sitesCache;

  /**
   * Show a list of your sites on Pantheon
   * @package Terminus
   * @version 2.0
   */
  public function __construct() {
    parent::__construct();
    Auth::loggedIn();

    $this->sitesCache = new SitesCache();
  }

  /**
   * Show all sites user has access to
   * Note: because of the size of this call, it is cached
   *   and also is the basis for loading individual sites by name
   *
   * @subcommand list
   * @alias show
   */
  public function index($args, $assoc_args) {
    // Always fetch a fresh list of sites
    $this->sitesCache->rebuild();
    $cached_sites = $this->sitesCache->all();

    if (count($cached_sites) == 0) {
      Terminus::log("You have no sites.");
      exit(0);
    }

    $rows = array_map(function($cached_site) {
      return array(
        'name' => $cached_site['name'],
        'id' => $cached_site['id'],
        'service_level' => $cached_site['service_level'],
        'framework' => $cached_site['framework'],
        'memberships' => array_map(function($membership) {
          return $membership['name'];
        }, array_values($cached_site['memberships']))
      );
    }, array_values($cached_sites));

    $this->handleDisplay($rows);
  }


  /**
   * Create a new site
   *
   * ## OPTIONS
   *
   * [--site=<site>]
   * : Name of the site to create (machine-readable)
   *
   * [--name=<name>]
   * : (deprecated) use --site instead
   *
   * [--label=<label>]
   * : Label for the site
   *
   * [--product=<productid>]
   * : Specify the upstream product to use
   *
   * [--import=<url>]
   * : A url to import a valid archive
   *
   * [--org=<org>]
   * : UUID of organization into which to add this site
   *
   */
  public function create($args, $assoc_args) {
    $options = array();
    $options['label'] = Input::string($assoc_args, 'label', "Human readable label for the site");
{'fraction_non_alphanumeric': 0.14517506404782238, 'fraction_numerical': 0.0017079419299743809, 'mean_word_length': 2.9469250210614995, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7354224', 'n_tokens_mistral': 1562, 'n_tokens_neox': 1496, 'n_words': 400}