Created
December 8, 2012 23:47
-
-
Save adatta02/4242571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyTasks { | |
public static $HELP_TEXT = array( | |
"listAllFiles" => "List all the files in the current directory", | |
"clearOldRows" => "Clear out old rows from the DB. (Or something like that)" | |
); | |
public static function listAllFiles(){ | |
foreach( glob("*") as $fn ){ | |
echo $fn . "\n"; | |
} | |
} | |
public static function clearOldRows(){ | |
/* Do something */ | |
} | |
} | |
// If nothing is being called just enumerate all the available functions | |
if( count($argv) == 1 ){ | |
echo "Available MyTasks methods:\n"; | |
$arr = array(); | |
foreach( get_class_methods("MyTasks") as $fn ){ $arr[] = $fn; } | |
sort($arr); | |
foreach( $arr as $fn ){ | |
echo "\033[0;32m" . $fn . "\033[0m\n"; | |
if( array_key_exists($fn, MyTasks::$HELP_TEXT) ){ | |
echo "\t" . MyTasks::$HELP_TEXT[$fn] . "\n"; | |
} | |
} | |
exit(0); | |
} | |
call_user_func( "MyTasks::" . $argv[1], $argv ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment