<commit_before>#!/usr/bin/php
<?php

require_once 'vendor/autoload.php';
require_once 'includes/functions.php';


$definitions = new \Clapp\CommandLineArgumentDefinition(array(
    "help|h"        => "Shows help message",
    "name|n=s"      => "name of component to generate",
    "dir|d=s"       => "base dir of where to create files",
    "namespace|s=s" => "base namespace of classes",
    "table|t=s"     => "MySQL table name",
    "stdout|o"   => "show code to stdout instead of writing files",
));

// Filter arguments based and validate according to definitions
$filter = new \Clapp\CommandArgumentFilter($definitions, $argv);

if ($filter->getParam('help') === true) {
    errorMessage("Usage {$argv[0]} [options]\n\n");
    errorMessage($definitions->getUsage());
    exit;
} //if

$valid = true;

$name = $filter->getParam("name");
if ($name === null) {
    $valid = false;

   errorMessage("You need to provide a name\n\n"); 
} //if

$dir = $filter->getParam("dir");
if ($dir === null) {
    $valid = false;

    errorMessage("You need to provide a base directory\n\n"); 
} else {

    $dir = rtrim($dir, "/");

    if (!is_dir($dir)) {
        $valid = false;
        errorMessage("You need to provide a valid directory\n\n");
    } //if

} //if

$namespace = $filter->getParam("namespace");
if ($namespace === null) {
    $valid = false;

   errorMessage("You need to provide a namespace\n\n"); 
} //if

$tableName = $filter->getParam("table");
if ($namespace === null) {
    $valid = false;

   errorMessage("You need to provide a MySQL table\n\n"); 
} //if

$outputCode = $filter->getParam("stdout");

if ($valid === false) {
    errorMessage("Usage {$argv[0]} [options]\n\n");
    errorMessage($definitions->getUsage());
    exit(2);
} //if

if (file_exists('./includes/config.php')) {
    $config = include('./includes/config.php');
} else {
    errorMessage("No config file found in includes/config.php\n\n");
    exit(2);
} //if

$twig = new Twig_Environment(new Twig_Loader_Filesystem(__DIR__ .'/templates'));

/* create namespace dir if it doesn't exist */

$namespaceDir = $dir . "/" . basename(str_replace("\\",'/', $namespace));<commit_msg>load includes relative to script __DIR__<commit_after>#!/usr/bin/php
<?php

require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/includes/functions.php';


$definitions = new \Clapp\CommandLineArgumentDefinition(array(
    "help|h"        => "Shows help message",
    "name|n=s"      => "name of component to generate",
    "dir|d=s"       => "base dir of where to create files",
    "namespace|s=s" => "base namespace of classes",
    "table|t=s"     => "MySQL table name",
    "stdout|o"   => "show code to stdout instead of writing files",
));

// Filter arguments based and validate according to definitions
$filter = new \Clapp\CommandArgumentFilter($definitions, $argv);

if ($filter->getParam('help') === true) {
    errorMessage("Usage {$argv[0]} [options]\n\n");
    errorMessage($definitions->getUsage());
    exit;
} //if

$valid = true;

$name = $filter->getParam("name");
if ($name === null) {
    $valid = false;

   errorMessage("You need to provide a name\n\n"); 
} //if

$dir = $filter->getParam("dir");
if ($dir === null) {
    $valid = false;

    errorMessage("You need to provide a base directory\n\n"); 
} else {

    $dir = rtrim($dir, "/");

    if (!is_dir($dir)) {
        $valid = false;
        errorMessage("You need to provide a valid directory\n\n");
    } //if

} //if

$namespace = $filter->getParam("namespace");
if ($namespace === null) {
    $valid = false;

   errorMessage("You need to provide a namespace\n\n"); 
} //if

$tableName = $filter->getParam("table");
if ($namespace === null) {
    $valid = false;

   errorMessage("You need to provide a MySQL table\n\n"); 
} //if

$outputCode = $filter->getParam("stdout");

if ($valid === false) {
    errorMessage("Usage {$argv[0]} [options]\n\n");
    errorMessage($definitions->getUsage());
    exit(2);
} //if

$configFilename = __DIR__ . '/includes/config.php';
if (file_exists($configFilename)) {
    $config = include($configFilename);
} else {
    errorMessage("No config file found in includes/config.php\n\n");
    exit(2);
} //if

$twig = new Twig_Environment(new Twig_Loader_Filesystem(__DIR__ .'/templates'));

/* create namespace dir if it doesn't exist */

$namespaceDir = $dir . "/" . basename(str_replace("\\",'/', $namespace));
{'fraction_non_alphanumeric': 0.18640996602491505, 'fraction_numerical': 0.001812004530011325, 'mean_word_length': 3.538540596094553, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '6835881', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1431, 'n_words': 371}