Skip to content

Commit

Permalink
Show help if called without args and no stdin redirection #2
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Jul 7, 2020
1 parent 19a63cc commit e35f55d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jsqry-cli.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as std from "std";
import * as os from "os";
import jsqry from "./jsqry.js";

const VERSION = "0.0.2";
Expand Down Expand Up @@ -103,7 +104,11 @@ const [params, args] = parseArgs();

if (params["-v"] || params["--version"]) {
print(VERSION);
} else if (params["-h"] || params["--help"]) {
} else if (
params["-h"] ||
params["--help"] ||
(os.isatty(std.in) && scriptArgs.length === 1) /* called with no params */
) {
print(`jsqry ver. ${VERSION}
Usage: echo $JSON | jsqry 'query'
-1,--first return first result element
Expand Down

0 comments on commit e35f55d

Please sign in to comment.