#!/usr/bin/env php
<?php

// Potential composer autoloader paths
$paths = array(
    __DIR__ . '/../vendor/autoload.php',
    __DIR__ . '/../../../autoload.php',
);

foreach($paths as $path) {

    if (file_exists($path)) {
        include $path;
        break;
    }

}

if ($argc < 3) {
    echo <<<HI
PHPDocumentor Markdown Generator

Usage:

    # First generate a structure.xml file with phpdocumentor.
    # This command will generate structure.xml in the current directory.
    phpdoc parse -t . -d [project path]

    # Next, run phpdocmd:
    {$argv[0]} structure.xml [outputdir]

HI;
    die();
}

$input = $argv[1];
$outputDir = $argv[2];


$parser = new PHPDocMD\Parser(
    $input
);

echo "Re-aligning ice-tea flasks\n";

$classDefinitions = $parser->run();

$templateDir = __DIR__ . '/../templates/';

$generator = new PHPDocMD\Generator(
    $classDefinitions,
    $outputDir,
    $templateDir
);

echo "Opening knapsack combusters\n";
$generator->run();

echo "Complete\n";
