File tree Expand file tree Collapse file tree 4 files changed +92
-0
lines changed
Expand file tree Collapse file tree 4 files changed +92
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ # Given a list of commands as JSON on STDIN, generates an HTML table with the
4+ # top-level commands.
5+ #
6+ # Example usage:
7+ #
8+ # wp --cmd-dump --path=/path/to/wp | php _utils/cmd-list.php
9+
10+ include __DIR__ . '/utils.php ' ;
11+
12+ $ wp = read_json ();
13+
14+ foreach ( $ wp ['subcommands ' ] as $ command ) {
15+ if ( !$ command ['internal ' ] )
16+ continue ;
17+
18+ echo <<<EOB
19+ <tr>
20+ <td><a href="https://github.com/wp-cli/wp-cli/blob/master/php/commands/ {$ command ['name ' ]}.php"> {$ command ['name ' ]}</a></td>
21+ <td> {$ command ['description ' ]}</td>
22+ </tr>
23+
24+ EOB ;
25+ }
26+
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # utility for comparing commands between two different wp-cli versions.
4+
5+ if [ $# -lt 3 ]; then
6+ echo ' usage: <version-a> <version-b> <wp-path>'
7+ exit 1
8+ fi
9+
10+ wp_path=$3
11+
12+ get_syn_list () {
13+ git checkout $1
14+ wp --path=$wp_path --cmd-dump | php $( dirname $0 ) /syn-list.php
15+ }
16+
17+ get_syn_list $1 > /tmp/wp-cli-a
18+ get_syn_list $2 > /tmp/wp-cli-b
19+
20+ diff /tmp/wp-cli-a /tmp/wp-cli-b > cmd.diff
21+
22+ echo ' Generated cmd.diff'
Original file line number Diff line number Diff line change 1+ <?php
2+ # Given a list of commands as JSON on STDIN, generates a list of synopses.
3+ #
4+ # Example usage:
5+ #
6+ # wp --cmd-dump --path=/path/to/wp | php _utils/syn-list.php
7+
8+ include __DIR__ . '/utils.php ' ;
9+
10+ function generate_synopsis ( $ command , $ path = '' ) {
11+ if ( isset ( $ command ['internal ' ] ) && !$ command ['internal ' ] )
12+ continue ;
13+
14+ $ full_path = $ path . ' ' . $ command ['name ' ];
15+
16+ if ( !isset ( $ command ['subcommands ' ] ) ) {
17+ echo $ full_path . ' ' . $ command ['synopsis ' ] . "\n" ;
18+ } else {
19+ foreach ( $ command ['subcommands ' ] as $ subcommand ) {
20+ generate_synopsis ( $ subcommand , $ full_path );
21+ }
22+ }
23+ }
24+
25+ generate_synopsis ( read_json () );
26+
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ function read_json () {
4+ $ input = '' ;
5+
6+ while ( false !== ( $ line = fgets ( STDIN ) ) ) {
7+ $ input .= $ line ;
8+ }
9+
10+ $ json = json_decode ( $ input , true );
11+ if ( !$ json ) {
12+ echo "Invalid JSON. " ;
13+ exit (1 );
14+ }
15+
16+ return $ json ;
17+ }
18+
You can’t perform that action at this time.
0 commit comments