GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support reading from stdin · phpmyadmin/sql-parser@a215a30

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/Utils
    • CLI.php
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/Utils/CLI.php‎

Copy file name to clipboardExpand all lines: src/Utils/CLI.php
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public function runHighlight()
7777

7878
return 0;
7979
}
80+
if (!isset($params['q'])) {
81+
if ($stdIn = $this->readStdin()) {
82+
$params['q'] = $stdIn;
83+
}
84+
}
8085
if (isset($params['q'])) {
8186
echo Formatter::format(
8287
$params['q'],
@@ -127,6 +132,11 @@ public function runLint()
127132
if (isset($params['c'])) {
128133
Context::load($params['c']);
129134
}
135+
if (!isset($params['q'])) {
136+
if ($stdIn = $this->readStdin()) {
137+
$params['q'] = $stdIn;
138+
}
139+
}
130140
if (isset($params['q'])) {
131141
$lexer = new Lexer($params['q'], false);
132142
$parser = new Parser($lexer->list);
@@ -177,6 +187,11 @@ public function runTokenize()
177187

178188
return 0;
179189
}
190+
if (!isset($params['q'])) {
191+
if ($stdIn = $this->readStdin()) {
192+
$params['q'] = $stdIn;
193+
}
194+
}
180195
if (isset($params['q'])) {
181196
$lexer = new Lexer($params['q'], false);
182197
foreach ($lexer->list->tokens as $idx => $token) {
@@ -199,4 +214,12 @@ public function runTokenize()
199214

200215
return 1;
201216
}
217+
218+
private function readStdin() {
219+
stream_set_blocking(STDIN, false);
220+
$stdin = stream_get_contents(STDIN);
221+
// restore-default block-mode setting
222+
stream_set_blocking(STDIN, true);
223+
return $stdin;
224+
}
202225
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.