Skip to content

Commit d9ef8ae

Browse files
authored
Merge pull request #243 from ibennetch/usage
Add usage hints for command line stdin
2 parents 7f4de0b + b1fd0fc commit d9ef8ae

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/Utils/CLI.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function mergeLongOpts(&$params, &$longopts)
3232
public function usageHighlight()
3333
{
3434
echo "Usage: highlight-query --query SQL [--format html|cli|text]\n";
35+
echo " cat file.sql | highlight-query\n";
3536
}
3637

3738
public function getopt($opt, $long)
@@ -100,6 +101,7 @@ public function runHighlight()
100101
public function usageLint()
101102
{
102103
echo "Usage: lint-query --query SQL\n";
104+
echo " cat file.sql | lint-query\n";
103105
}
104106

105107
public function parseLint()
@@ -159,6 +161,7 @@ public function runLint()
159161
public function usageTokenize()
160162
{
161163
echo "Usage: tokenize-query --query SQL\n";
164+
echo " cat file.sql | tokenize-query\n";
162165
}
163166

164167
public function parseTokenize()

tests/Utils/CLITest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ public function highlightParams()
8383
],
8484
[
8585
['h' => true],
86-
'Usage: highlight-query --query SQL [--format html|cli|text]' . "\n",
86+
'Usage: highlight-query --query SQL [--format html|cli|text]' . "\n" .
87+
' cat file.sql | highlight-query' . "\n",
8788
0,
8889
],
8990
[
9091
[],
9192
'ERROR: Missing parameters!' . "\n" .
92-
'Usage: highlight-query --query SQL [--format html|cli|text]' . "\n",
93+
'Usage: highlight-query --query SQL [--format html|cli|text]' . "\n" .
94+
' cat file.sql | highlight-query' . "\n",
9395
1,
9496
],
9597
[
@@ -136,13 +138,15 @@ public function lintParams()
136138
],
137139
[
138140
['h' => true],
139-
'Usage: lint-query --query SQL' . "\n",
141+
'Usage: lint-query --query SQL' . "\n" .
142+
' cat file.sql | lint-query' . "\n",
140143
0,
141144
],
142145
[
143146
[],
144147
'ERROR: Missing parameters!' . "\n" .
145-
'Usage: lint-query --query SQL' . "\n",
148+
'Usage: lint-query --query SQL' . "\n" .
149+
' cat file.sql | lint-query' . "\n",
146150
1,
147151
],
148152
[
@@ -189,13 +193,15 @@ public function tokenizeParams()
189193
],
190194
[
191195
['h' => true],
192-
'Usage: tokenize-query --query SQL' . "\n",
196+
'Usage: tokenize-query --query SQL' . "\n" .
197+
' cat file.sql | tokenize-query' . "\n",
193198
0,
194199
],
195200
[
196201
[],
197202
'ERROR: Missing parameters!' . "\n" .
198-
'Usage: tokenize-query --query SQL' . "\n",
203+
'Usage: tokenize-query --query SQL' . "\n" .
204+
' cat file.sql | tokenize-query' . "\n",
199205
1,
200206
],
201207
[

0 commit comments

Comments
 (0)