CODE STYLE, changes
FILES: gulliver/system/class.database_mssql.php gulliver/system/class.database_mysql.php workflow/engine/classes/class.cli.php workflow/engine/classes/class.pluginRegistry.php workflow/engine/classes/entities/FacetGroup.php workflow/engine/classes/entities/SolrUpdateDocument.php workflow/engine/classes/triggers/class.pmTalendFunctions.php workflow/engine/methods/appFolder/appFolderList.php workflow/engine/methods/processes/processes_Ajax.php
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
class CLI
|
||||
{
|
||||
public static $tasks = array ();
|
||||
public static $currentTask = NULL;
|
||||
public static $currentTask = null;
|
||||
|
||||
/**
|
||||
* Adds a new task defined by it's name.
|
||||
@@ -46,7 +46,7 @@ class CLI
|
||||
public static function taskName ($name)
|
||||
{
|
||||
self::$currentTask = $name;
|
||||
self::$tasks[$name] = array ('name' => $name,'description' => NULL,'args' => array (),'function' => NULL,'opt' => array ('short' => '','long' => array (),'descriptions' => array ()
|
||||
self::$tasks[$name] = array ('name' => $name,'description' => null,'args' => array (),'function' => null,'opt' => array ('short' => '','long' => array (),'descriptions' => array ()
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class CLI
|
||||
*/
|
||||
public static function taskDescription ($description)
|
||||
{
|
||||
assert( self::$currentTask !== NULL );
|
||||
assert( self::$currentTask !== null );
|
||||
self::$tasks[self::$currentTask]["description"] = $description;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class CLI
|
||||
*/
|
||||
public static function taskArg ($name, $optional = true, $multiple = false)
|
||||
{
|
||||
assert( self::$currentTask !== NULL );
|
||||
assert( self::$currentTask !== null );
|
||||
self::$tasks[self::$currentTask]["args"][$name] = array ('optional' => $optional,'multiple' => $multiple
|
||||
);
|
||||
}
|
||||
@@ -87,14 +87,16 @@ class CLI
|
||||
* @param string $short short options
|
||||
* @param array $long long options
|
||||
*/
|
||||
public static function taskOpt ($name, $description, $short, $long = NULL)
|
||||
public static function taskOpt ($name, $description, $short, $long = null)
|
||||
{
|
||||
assert( self::$currentTask !== NULL );
|
||||
assert( self::$currentTask !== null );
|
||||
$opts = self::$tasks[self::$currentTask]["opt"];
|
||||
if ($short)
|
||||
if ($short) {
|
||||
$opts['short'] .= $short;
|
||||
if ($long)
|
||||
}
|
||||
if ($long) {
|
||||
$opts['long'][] = $long;
|
||||
}
|
||||
$opts['descriptions'][$name] = array ('short' => $short,'long' => $long,'description' => $description
|
||||
);
|
||||
self::$tasks[self::$currentTask]["opt"] = $opts;
|
||||
@@ -107,7 +109,7 @@ class CLI
|
||||
*/
|
||||
public static function taskRun ($function)
|
||||
{
|
||||
assert( self::$currentTask !== NULL );
|
||||
assert( self::$currentTask !== null );
|
||||
self::$tasks[self::$currentTask]["function"] = $function;
|
||||
}
|
||||
|
||||
@@ -117,14 +119,15 @@ class CLI
|
||||
* @param array $args if defined, the task name should be argument 0
|
||||
* @param array $opts options as returned by getopt
|
||||
*/
|
||||
public static function help ($args, $opts = NULL)
|
||||
public static function help ($args, $opts = null)
|
||||
{
|
||||
global $argv;
|
||||
$scriptName = $argv[0];
|
||||
if (is_array( $args ))
|
||||
if (is_array( $args )) {
|
||||
$taskName = $args[0];
|
||||
else
|
||||
} else {
|
||||
$taskName = $args;
|
||||
}
|
||||
|
||||
if (! $taskName) {
|
||||
echo "usage: $scriptName <task> [options] [args]\n";
|
||||
@@ -142,10 +145,12 @@ class CLI
|
||||
$valid_args = array ();
|
||||
foreach (self::$tasks[$taskName]['args'] as $arg => $data) {
|
||||
$arg = strtoupper( $arg );
|
||||
if ($data['multiple'])
|
||||
if ($data['multiple']) {
|
||||
$arg = "$arg...";
|
||||
if ($data['optional'])
|
||||
}
|
||||
if ($data['optional']) {
|
||||
$arg = "[$arg]";
|
||||
}
|
||||
$valid_args[] = $arg;
|
||||
}
|
||||
$valid_args = join( " ", $valid_args );
|
||||
@@ -162,10 +167,12 @@ EOT;
|
||||
$valid_options = array ();
|
||||
foreach (self::$tasks[$taskName]['opt']['descriptions'] as $opt => $data) {
|
||||
$optString = array ();
|
||||
if ($data['short'])
|
||||
if ($data['short']) {
|
||||
$optString[] = "-{$data['short']}";
|
||||
if ($data['long'])
|
||||
}
|
||||
if ($data['long']) {
|
||||
$optString[] = "--{$data['long']}";
|
||||
}
|
||||
$valid_options[] = " " . join( ", ", $optString ) . "\n\t" . wordwrap( $data['description'], 70, "\n\t" );
|
||||
}
|
||||
$valid_options = join( "\n", $valid_options );
|
||||
@@ -194,14 +201,15 @@ EOT;
|
||||
$args = $argv;
|
||||
$cliname = array_shift( $args );
|
||||
$taskName = array_shift( $args );
|
||||
while ($taskName{0} == '-')
|
||||
while ($taskName{0} == '-') {
|
||||
$taskName = array_shift( $args );
|
||||
}
|
||||
if (! $taskName) {
|
||||
echo self::error( "Specify a task from the list below." ) . "\n\n";
|
||||
self::help( NULL, NULL );
|
||||
self::help( null, null );
|
||||
return;
|
||||
}
|
||||
$taskData = NULL;
|
||||
$taskData = null;
|
||||
foreach (self::$tasks as $name => $data) {
|
||||
if (strcasecmp( $name, $taskName ) === 0) {
|
||||
$taskData = $data;
|
||||
@@ -210,7 +218,7 @@ EOT;
|
||||
}
|
||||
if (! $taskData) {
|
||||
echo self::error( "Command not found: '$taskName'" ) . "\n\n";
|
||||
self::help( NULL, NULL );
|
||||
self::help( null, null );
|
||||
return;
|
||||
}
|
||||
G::LoadThirdParty( 'pear/Console', 'Getopt' );
|
||||
@@ -238,12 +246,15 @@ EOT;
|
||||
self::help( $taskName );
|
||||
return;
|
||||
}
|
||||
if (strpos( $optName, '--' ) === 0)
|
||||
if (strpos( $optName, '--' ) === 0) {
|
||||
$optName = substr( $optName, 2 );
|
||||
if (! array_key_exists( $optName, $validOpts ))
|
||||
}
|
||||
if (! array_key_exists( $optName, $validOpts )) {
|
||||
throw new Exception( "option not found: $optName" );
|
||||
if (array_key_exists( $validOpts[$optName], $taskOpts ))
|
||||
}
|
||||
if (array_key_exists( $validOpts[$optName], $taskOpts )) {
|
||||
throw new Exception( "'$optName' specified more then once" );
|
||||
}
|
||||
$taskOpts[$validOpts[$optName]] = $optArg;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
@@ -323,18 +334,18 @@ EOT;
|
||||
* @param string $message the message to display
|
||||
* @param string $filename the log file to write messages
|
||||
*/
|
||||
public static function logging ($message, $filename = NULL)
|
||||
public static function logging ($message, $filename = null)
|
||||
{
|
||||
static $log_file = NULL;
|
||||
static $log_file = null;
|
||||
if (isset( $filename )) {
|
||||
$log_file = fopen( $filename, "a" );
|
||||
fwrite( $log_file, " -- " . date( "c" ) . " " . $message . " --\n" );
|
||||
} else {
|
||||
if (isset( $log_file ))
|
||||
if (isset( $log_file )) {
|
||||
fwrite( $log_file, $message );
|
||||
}
|
||||
echo $message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user