From b8f9cf653c717832703cab025d7c476f6dcac7ae Mon Sep 17 00:00:00 2001 From: scribu Date: Tue, 1 Jan 2013 21:49:30 +0200 Subject: [PATCH] move read_json() to separate file --- utils/syn-list.php | 16 +--------------- utils/utils.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 utils/utils.php diff --git a/utils/syn-list.php b/utils/syn-list.php index 02e69b0a..4534d69c 100644 --- a/utils/syn-list.php +++ b/utils/syn-list.php @@ -5,21 +5,7 @@ # # wp --cmd-dump | php /path/to/wp-cli/utils/syn-list.php -function read_json() { - $input = ''; - - while ( false !== ( $line = fgets( STDIN ) ) ) { - $input .= $line; - } - - $json = json_decode( $input, true ); - if ( !$json ) { - echo "Invalid JSON."; - exit(1); - } - - return $json; -} +include __DIR__ . '/utils.php'; function generate_synopsis( $command, $path = '' ) { $full_path = $path . ' ' . $command['name']; diff --git a/utils/utils.php b/utils/utils.php new file mode 100644 index 00000000..eda9c6e1 --- /dev/null +++ b/utils/utils.php @@ -0,0 +1,18 @@ +