forked from thaliaarchi/wsjq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.jq
27 lines (25 loc) · 952 Bytes
/
main.jq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) 2021-2023 Thalia Archibald
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
include "ws";
(if $on_eof == "error" or $on_eof == null then "error"
else
try ($on_eof | tonumber | if . != trunc then error else . end)
catch ("Invalid value for --on-eof: \"\($on_eof)\"\n" |
prefix_error | halt_error(2))
end) as $on_eof |
$src | parse |
.on_eof = $on_eof |
.eof = $no_prompt == "true" |
.check_clean = $check_clean == "true" |
.check_retrieve = $check_retrieve == "true" |
.filename = $filename |
if $mode == "run" then interpret
elif $mode == "debug" then debug
elif $mode == "disasm" then disasm_pc
elif $mode == "parse" then stat
else "\($mode|tojson) is not a valid mode\n" | halt_error(2)
end |
if $mode != "parse" then select(type == "string") else . end