Skip to content

Commit

Permalink
Cleaned up fbcmd_include support
Browse files Browse the repository at this point in the history
  • Loading branch information
dtompkins committed Oct 15, 2009
1 parent 65c7a2e commit 7c15c99
Showing 3 changed files with 20 additions and 17 deletions.
10 changes: 7 additions & 3 deletions fbcmd.php
Original file line number Diff line number Diff line change
@@ -411,7 +411,9 @@
AddCommand('WHOAMI', '<no parameters>~Display the currently authorized user');

if (isset($fbcmd_include_newCommands)) {
array_merge_unique($fbcmdCommandList,$fbcmd_include_newCommands);
foreach ($fbcmd_include_newCommands as $c) {
AddCommand($c[0],$c[1]);
}
}

////////////////////////////////////////////////////////////////////////////////
@@ -661,8 +663,10 @@
////////////////////////////////////////////////////////////////////////////////

if (isset($fbcmd_include_newCommands)) {
if (in_array($fbcmdCommand,$fbcmd_include_newCommands)) {
return;
foreach ($fbcmd_include_newCommands as $c) {
if ($fbcmdCommand == $c[0]) {
return;
}
}
}

11 changes: 4 additions & 7 deletions support/fbcmd_include.php
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@

// This is a support file for inclding FBCMD within other programs

function FbcmdInitInclude() {
function FbcmdIncludeInit() {
global $argv;
global $argc;
global $fbcmd_argv;
@@ -43,19 +43,16 @@ function FbcmdInitInclude() {
ob_start();
}

function FbcmdAddArgument($p) {
function FbcmdIncludeAddArgument($p) {
global $fbcmd_argv;
global $fbcmd_argc;
$fbcmd_argv[] = $p;
$fbcmd_argc++;
}

function FbcmdAddCommands() {
function FbcmdIncludeAddCommand($cmd, $help) {
global $fbcmd_include_newCommands;
$newCommands = func_get_args();
foreach ($newCommands as $cmd) {
$fbcmd_include_newCommands[] = $cmd;
}
$fbcmd_include_newCommands[] = array($cmd,$help);
}

?>
16 changes: 9 additions & 7 deletions support/my_fbcmd.php
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
// This is a sample program to show how to create your own COMMAND(S) for FBCMD
// see: http://fbcmd.dtompkins.com/help/how-to/add-command for more info.

// *** WARNING: Do *NOT* modify this file: if you use the fbcmd_update utility
// *** WARNING: Do *NOT* modify this file: if you use the fbcmd UPDATE
// this file will be updated & replaced. Create your own instead.

// If you have a new command and would like to share it with others, visit:
@@ -37,18 +37,20 @@
////////////////////////////////////////////////////////////////////////////////
// Step Two: Run the FbcmdInitInclude() procedure

FbcmdInitInclude();
FbcmdIncludeInit();

////////////////////////////////////////////////////////////////////////////////
// Step Three: Add any arguments to be appended
// Step Three: Add any arguments to be appended automatically

FbcmdAddArgument('-quiet=0');
FbcmdAddArgument('-facebook_debug=0');
FbcmdIncludeAddArgument('-quiet=0');
FbcmdIncludeAddArgument('-facebook_debug=0');

////////////////////////////////////////////////////////////////////////////////
// Step Four: List your new commands so that FBCMD will recognize them

FbcmdAddCommands('FRIENDNAMES','MYNOTES','SINGLE');
FbcmdIncludeAddCommand('FNAMES','Display all your friend\'s names');
FbcmdIncludeAddCommand('MYNOTES','Display all of your notes');
FbcmdIncludeAddCommand('SINGLE','Display all of your single friends');

////////////////////////////////////////////////////////////////////////////////
// Step Five: Include (run) FBCMD
@@ -58,7 +60,7 @@
////////////////////////////////////////////////////////////////////////////////
// Step Six: Add your own commands:

if ($fbcmdCommand == 'FRIENDNAMES') {
if ($fbcmdCommand == 'FNAMES') {
GetFlistIds("=all");
foreach ($flistMatchArray as $friendId) {
print ProfileName($friendId) . "\n";

0 comments on commit 7c15c99

Please sign in to comment.