OSDN Git Service

move read_json() to separate file
authorscribu <mail@scribu.net>
Tue, 1 Jan 2013 19:49:30 +0000 (21:49 +0200)
committerscribu <mail@scribu.net>
Tue, 1 Jan 2013 20:36:44 +0000 (22:36 +0200)
utils/syn-list.php
utils/utils.php [new file with mode: 0644]

index 02e69b0..4534d69 100644 (file)
@@ -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 (file)
index 0000000..eda9c6e
--- /dev/null
@@ -0,0 +1,18 @@
+<?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;
+}
+