-
Notifications
You must be signed in to change notification settings - Fork 57
/
sprint
executable file
·101 lines (77 loc) · 2.45 KB
/
sprint
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
#!/usr/bin/env php
<?php
include 'vendor/autoload.php';
use Myth\CLI as CLI;
$status = 0;
$extra = '';
/**
* Relative location to the application's
* index.php from this file.
*/
$fcpath = 'index.php';
$apppath = 'application/';
/**
* Refuse to run oil when called from php-cgi !
*/
if (substr(php_sapi_name(), 0, 3) == 'cgi')
{
die("This is not supported when running php-cgi. Sprint needs php-cli to function!\n\n");
}
/**
* Set error reporting and display errors settings. You will want to change these when in production.
*/
error_reporting(-1);
ini_set('display_errors', 1);
//--------------------------------------------------------------------
// Do the Things
//--------------------------------------------------------------------
// Default to a simple passthru of the basic command, less arguments.
$command = CLI::cli_string();
// Check all arguments that we're interested in here
$options = CLI::getOptions();
//--------------------------------------------------------------------
// Help Command
//--------------------------------------------------------------------
// If -h or --help or -help are present, then we'll return the command's
// Long description, if available.
//
if ( array_key_exists('h', $options) || array_key_exists('help', $options)) {
$command = CLI::segment(1) . ' longDescribeMethod ' . CLI::segment(2);
}
//--------------------------------------------------------------------
// Show Version
//--------------------------------------------------------------------
// If -v or --version is present, then we'll return Sprint's current
// version.
//
if ( array_key_exists('v', $options) || array_key_exists('version', $options) )
{
define('BASEPATH', true);
require $apppath .'config/constants.php';
$output = '';
if (defined('SPRINT_VERSION'))
{
$output .= 'Running Sprint v'. CLI::color(SPRINT_VERSION, 'yellow');
}
if (defined('BONFIRE_VERSION'))
{
$output .= ' and Bonfire v'. CLI::color(BONFIRE_VERSION, 'yellow');
}
CLI::write($output);
exit(0);
}
//--------------------------------------------------------------------
// Standard Method call to CodeIgniter
//--------------------------------------------------------------------
//
if (! $command)
{
CLI::new_line();
CLI::write('You must pass a valid command to sprint.', 'yellow');
CLI::new_line();
}
else {
$options = CLI::optionString();
passthru( "php {$fcpath} {$command} {$options}", $status );
}
exit($status);