Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 103 lines (85 sloc) 2.93 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
<?php
/**
* cakespec.php - CakePHP Application Builder - Command line tool
* @version 0.9
* @author Jonathan Cutrer
*
*/

include_once('bootstrap.php');

//Parse command line options
$cliOpts = getopt('qhlvd', array('quiet', 'help', 'lint', 'version', 'debug', 'nodep', 'notagline') );

//Parse command line arguments
$cliArgs = cakespec_getargs( $argv );

// Process -h --help flags and exit
if ( array_key_exists( 'h', $cliOpts ) || array_key_exists( 'help', $cliOpts ) ) {
     cakespec_help();
     exit;
}

// Process -v --version flags and exit
if ( array_key_exists( 'v', $cliOpts ) || array_key_exists( 'version', $cliOpts ) ) {
     echo CAKESPEC_VERSION . "\n";
     exit;
}

// Process -q --quiet flags
if ( array_key_exists( 'q', $cliOpts ) || array_key_exists( 'quite', $cliOpts ) ) {
     define( 'CAKESPEC_QUIET', 1 );
} else {
     defined('CAKESPEC_QUIET') or define('CAKESPEC_QUIET', 0);
}

// Process -d --debug flags
if ( array_key_exists( 'd', $cliOpts ) || array_key_exists( 'debug', $cliOpts ) ) {
     define( 'CAKESPEC_DEBUG', 1 );
     cakespec_debug( '--debug flag set, turning debug on' );
} else {
     defined('CAKESPEC_DEBUG') or define('CAKESPEC_DEBUG', 0);
}

// Process --nodep flag
if ( array_key_exists( 'nodep', $cliOpts ) ) {
     defined('CAKESPEC_NODEP') or define( 'CAKESPEC_NODEP', 1 );
}

//Check CakeSpec dependencies
if (!defined('CAKESPEC_NODEP') ) {
    cakespec_checkDependencies();
}

// Process --notagline flag
if ( array_key_exists( 'notagline', $cliOpts ) ) {
     defined('CAKESPEC_NOTAGLINE') or define( 'CAKESPEC_NOTAGLINE', 1 );
}

//Parse [FILE] command line argument, if not set show syntax and exit
if ( empty( $cliArgs[1] ) ) {
    cakespec_syntax();
    exit;
} else {
    $specfile = $cliArgs[1];
}

// Process -l --lint flag and exit
if ( array_key_exists( 'l', $cliOpts ) || array_key_exists( 'lint', $cliOpts ) ) {
     cakespec_debug( '--lint flag set, running lint' );
     $CsLint = new CakeSpecLint( $specfile );
     exit;
}

// Create instance of CakeSpecBuilder and run ::build()
$Builder = new CakeSpecBuilder( $specfile );
$Builder->build();
exit;
/* end execution */

/* Functions below */
function cakespec_syntax() {
    global $argv;
    echo "Usage: cakespec [OPTION] [FILE]\n";
    echo "Try cakespec --help for more information.\n";
}

function cakespec_help() {
    echo <<<END
Usage: cakespec [OPTION] [FILE]
Example: cakespec myapp.cakespec

Command Line Arguments:
-h, --help display this help and exit
-v, --version print version information and exit
-l, --lint PATTERN is a basic regular expression (BRE)
-q, --quiet suppress all normal output
-d, --debug output detailed debugging information
--nodep no dependency checks for git, svn, etc
--notagline suppress 'generated using CakeSpec' tagline from generated files


END;
}
Something went wrong with that request. Please try again.